Posts

Showing posts with the label Lambda Function!

What's Exactly Lambda Function? Figure Out It's Purpose, Usages, Advantages and Limitations+ Much More

Image
Abstract : A lambda function is a small anonymous function. A lambda function can take any number of arguments, but can only have one expression. Syntax lambda  arguments  :  expression The expression is executed and the result is returned: Why Use Lambda Functions? The power of lambda is better shown when you use them as an anonymous function inside another function. Say you have a function definition that takes one argument, and that argument will be multiplied with an unknown number: def  myfunc(n):    return   lambda  a : a * n Use that function definition to make a function that always doubles the number you send in: Example def  myfunc(n):    return   lambda  a : a * n mydoubler = myfunc( 2 ) print (mydoubler( 11 )) Linked lists may be more memory efficient than arrays for large data structures, as linked lists only allocate space to data elements and their pointers to the next element; arrays require allocating memory for every possible element regardless of whether