f::map (public)

 f::map f xs

Defined in packages/acs-tcl/tcl/ad-functional-procs.tcl

Takes 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

Partial Call Graph (max 5 caller/called nodes):
%3 f::all f::all (public) f::map f::map f::all->f::map f::any f::any (public) f::any->f::map f::pascal f::pascal (public, deprecated) f::pascal->f::map

Testcases:
No testcase defined.
Source code:
    set result {}
    foreach x $xs {
        lappend result [$f $x]
    }
    return $result
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: