LMAP


lists
Since v1.0.0
Available on all platforms
See also

The LMAP function applies a macro on each element of a list, producing a list with the element on top of the stack after each macro invocation.

The macro is called with a stack containing the list index on top and the element at that particular index below it.

Signature

Examples

[ 42 21 11 ] <% DROP 2 * %> //ignore the index, double the result LMAP //do the same thing with FOREACH [] //new list [ 42 21 11 ] <% 2 * +! %> //append value*2 on the list FOREACH
//macro to print "list[i]: value" string <% TOSTRING //convert index in string 'list[' SWAP + //concatenate list[ before the index ']=' + //concatenate ]= SWAP //place value on top of the stack TOSTRING + //convert value in string, concatenate to the string %> 'mymacro' STORE [ 42 21 11 ] $mymacro LMAP