On Wednesday, August 10, 2016 at 8:37:18 PM UTC+2, Todd Zimmerman wrote:
>
> Is there any significant difference in SageMath between defining a 
> function using lambda vs. defining it using 'def ...:'? 
>
>
This is actually a pure Python question, and the answer is yes. Technically:

def f1(x):
    return x

f2 = lambda x : x

import dis # disassembler


dis.dis(f1)

2 0 LOAD_FAST 0 (x)
  3 RETURN_VALUE   

dis.dis(f2)

1 0 LOAD_FAST 0 (x)
  3 RETURN_VALUE 



But you cannot integrate or differentiate them! For that, you need a 
function/symbolic expression, which is a Sage-specific object!

Under the hood, f(x) = x is constructed like:

x = var("x")
f = symbolic_expression(x).function(x)


-- harald

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.

Reply via email to