Defined in tcl/ad-functional.tclTakes a function f and a list { x1 x2 x3 ...},
applies the function on each element of the list
and returns the result, i.e. { f x1, f x2, f x3, ...}.
Examples
(fib = fibonacci function, sqr = square function)
- Applying a function to each element of a list:
map fib [list 0 1 2 3 4 5 6 7 8] = {0 1 1 2 3 5 8 13 21}
- Applying a function to each element of a matrix (a list of lists)
can be done with a nested call:
map [lambda {row} {map sqr $row}] [list [list 1 2 3] [list 4 5 6]] = {{1 4 9} {16 25 36}}
- Parameters:
-
f
xs