OpenMusic Reference
flat
flat
(lists module) -- removes imbrication (nesting) from lists
Syntax
flat lst &optional level
Inputs
name | data type(s) | comments |
---|---|---|
lst | a tree | |
level | a non-negative integer | |
lst? | any |
Output
output | data type(s) | comments |
---|---|---|
first | a tree |
Description
Returns a copy of list with parentheses removed. By default, flat removes all levels of nesting, returning a list whose only parentheses are those which enclose it, a ‘flat’ list.
When the optional input is used, only level levels of parentheses are removed, starting from the outside. Setting level to 0 will thus return the list unchanged. Leaving level at nil will remove all levels of nesting.
Examples
Flattening a list
Here, the list is flattened completely:
? OM->(1 2 a 3 b 4)
Here, the optional input level has been set to 2. Only the two outside levels of nesting have been removed, leaving one intact:
? OM->(1 (2 a) (3 b) 4)
Prev | Home | Next |
---|---|---|
first-n | Up | floor |