Command: forall

NEST HelpDesk Command Index NEST Quick Reference

Name:
 forall - Call a procedure for each element of a list/string/dictionary

Synopsis:
     [v1 ... vn] {f}                   forall ->  f(v1) ... f(vn)
     (c1...cn)   {f}                   forall ->  f(c1) ... f(cn)
     <> {f} forall ->  f(/key1 val1) ... f(/keyn valn)

Parameters:
     [v1,...,vn]    - list of n arbitrary objects
     (c1...cn)      - arbitrary string
     <> - arbitrary dictionary
     {f}            - function which can operate on the elements of the
                      array, or on key/value pairs of the dictionary.
                      f is not required to return a specific number
		      of values.

Description:
     Arrays:
       For each element of the input array, forall calls f.
       forall is similar to Map, however, it does not construct a
       new list from the return values.

     Dictionaries:
       For each key/value pair of the dictionary, forall calls f.
       Order on the operand stack will be: key, value. (I.e. value on top.)
 
       *Note: The dictionary contents are copied before operation.
        This can be a potentially expensive operation.*

     Loops can be nested. The loop can be quit prematurely with exit.

Examples:
     [1 2 3 4 5]  {=} forall -> - % Print all values of the list
     [1 2 3 4 5]  {} forall  -> 1 2 3 4 5
     (abc) {=} forall -> prints 97 98 99 on separate lines
     <> {== ==} forall -> prints 1 /a 2 /b on separate lines

Author:
     Marc-Oliver Gewaltig, Ruediger Kupper (dictionary variant)

References:
 The Red Book

SeeAlso:Map MapAt MapIndexed Table forallindexed NestList FoldList Fold exit
Source:
 /home/abuild/rpmbuild/BUILD/nest-2.4.1/sli/slicontrol.cc

NEST HelpDesk Command Index NEST Quick Reference

© 2000-2010 The NEST Initiative