Loading

LFLATMAP

lists

The LFLATMAP 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. Since Warp 10 2.4.0, you can override this behaviour with a boolean.

Difference with LMAP: if the macro returns a list, then LFLATMAP will produce a list with the elements of the macro output list (i.e. it will flatten the list).

Difference with LMAP FLATTEN: flatten will do the list flattening recursively.

LFLATMAP is available since version 1.0.0.

See also

Signature

Examples

<% DROP //ignore index 'valuemap' STORE [ //build a list 0 $valuemap VALUELIST <% + %> FOREACH //sum the values in the map $valuemap KEYLIST //list the keys ] //returns the list %> 'cartsumup' STORE [ { 'apple' 4 'lemon' 2 } { 'banana' 5 'apple' 8 'orange' 1 } ] $cartsumup LMAP [ { 'apple' 4 'lemon' 2 } { 'banana' 5 'apple' 8 'orange' 1 } ] $cartsumup LFLATMAP [ { 'apple' 4 'lemon' 2 } { 'banana' 5 'apple' 8 'orange' 1 } ] $cartsumup LMAP FLATTEN