Skip to content

Instantly share code, notes, and snippets.

@toomasv
Created August 28, 2017 19:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save toomasv/f9730db91c365bf1ed94453028bfc1c0 to your computer and use it in GitHub Desktop.
Save toomasv/f9730db91c365bf1ed94453028bfc1c0 to your computer and use it in GitHub Desktop.
Flatten up to certain level
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