# Revision history [back]

Your question is very much valid. This notation to define a function (which is specific to Sage, and which creates a kind of function object) sadly does not seem to behave well except in the simplest cases. This is a bug.

I recommend not using this function notation. Instead, for one-line functions try (as in Python):

f = lambda a, b: gcd(a, b)


and for more complicated ones:

def f(a, b):
# possibly more statements here
return gcd(a, b)


Your question is very much valid. This notation to define a function (which is specific to Sage, and which creates a kind of function object) sadly does not seem to behave well except in the simplest cases. This is a bug.

I recommend not using this function notation. Instead, for one-line functions try (as in Python):

f = lambda a, b: gcd(a, b)


and for more complicated ones:

def f(a, b):
# possibly more statements here
return gcd(a, b)


By the way, the result you got probably stems from the following:

sage: var('a b')
(a, b)
sage: gcd(a, b)
1