Created
August 28, 2017 19:58
-
-
Save toomasv/f9730db91c365bf1ed94453028bfc1c0 to your computer and use it in GitHub Desktop.
Flatten up to certain level
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
flatten: func [tree [block!] /level lvl /local rule l][ | |
(l: -1) | |
rule: [(l: l + 1) some [ | |
ahead block! if (any [not level l < lvl]) into rule (l: l - 1) | |
| keep skip | |
| none | |
]] | |
parse tree [collect rule] | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment