Thursday, July 24, 2008

Boxing Calisthenics Routine

lambda functions in python

Hello!

Today I wanted to explain what are the lambda functions in python!

In practice due to the short form of lambda functions we can write in-line, this way you save time and code is much more beautiful to behold!

Here is an example:

def raises (x): return x ** 2

This function passed to it as an argument a number (Variable x) returns the value squared.

That raises (3) = 9!

Let's see how we can do with lambda functions:

g = lambda x: x ** 2

As first
g (3) = 9!

lambda functions have been "inherited" from LISP, and I'm happy because with this method saves labor and lines of code!

I made just one example why I'm working on a small script with the "normal" and the features created by the method "lambda"!

Hi all!

ballot

0 comments:

Post a Comment