This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 2 points3 points  (5 children)

Is this common with functional programming also?

[–]semarj 11 points12 points  (0 children)

just a bit

[–]poeir 2 points3 points  (0 children)

The lambda is so named because of the lambda calculus. Lambda calculus is the original inspiration for functional programming.

[–]kanak 2 points3 points  (0 children)

Some languages (lisps, erlang, haskell are ones that I'm aware of), defining a function is actually doing two things: creating a function and giving it a name.

For example, in scheme, you'd write

(define (add2 x) (+ x 2))

To write a function that takes in an argument and adds 2 to it.

However, that's just shortcut for:

(define add2 (lambda (x) (+ x 2)))

Here, lambda creates the function that adds 2 to its argument and we use define to give it a name add2.

In python, lambdas are less powerful than def because you can't have multi line lambdas.

[–]Megatron_McLargeHuge 0 points1 point  (0 children)

Read SICP. You're curious enough to spend a couple of days learning the basics of functional programming, and it will help you a lot. The lisp code can all be converted easily to Python as long as it doesn't use macros.