lambda

EveAndersson.com : API Browser : lambda

lambda

lambda args body
Defined in tcl/ad-functional.tcl

The lambda function - one of the foundations of functional programming - defines an anonymous proc and returns it. This is useful if you quickly need an auxiliary function for a small task.

Examples

  • map [lambda {x} {expr $x*$x}] {1 2 3 4 5}
    = {1 4 9 16 25}
  • zip_with [lambda {x y} {return "$x and $y"}] {1 2 3} {4 5 6}
    = "1 and 4" "2 and 5" "3 and 6"

Note

Although lambda defines a proc and therefore consumes memory, executing the same lambda expression twice will just re-define this proc. Thus, there is no memory leak, if you have a lambda inside a loop.

Parameters:
args
body
[ show source ]

Show another procedure:

eve@eveandersson.com