Next: , Previous: , Up: chains   [Index]


35.7 Mapping chains

The following syntactic bindings are exported by the library (vicare containers chains). The bindings whose name is prefixed with $ are unsafe operations: they do not validate their arguments before accessing them.

Function: chain-map-forwards fun chain0 chain
Function: $chain-map-forwards fun chain0 chain

Map the procedure fun over the chain arguments; build and return a new chain holding the results of the application. The iteration starts from the link given as argument, then it proceeds in the forwards direction; the iteration stops when reaching the end of one of the chain arguments.

Function: chain-for-each-forwards fun chain0 chain
Function: $chain-for-each-forwards fun chain0 chain

Apply the procedure fun over the chain arguments; discard the results. The last procedure application is performed in tail position, so its return value is the return value of the iteration; if one of the arguments is null: the return value is ‘#!void’. The iteration starts from the link given as argument, then it proceeds in the forwards direction; the iteration stops when reaching the end of one of the chain arguments.