Skip to content

Instantly share code, notes, and snippets.

@toomasv
Last active April 23, 2017 15:26
Show Gist options
  • Save toomasv/90107dbf233e7f7bde16c59462305181 to your computer and use it in GitHub Desktop.
Save toomasv/90107dbf233e7f7bde16c59462305181 to your computer and use it in GitHub Desktop.
Break a block into pieces using the provided delimiter
Red [Author: "Toomas Vooglaid"
Adapted-from: "split"
Date: "2017-04-23"
Version: "0.1"
]
split-block: func [
{Break a block into pieces using the provided delimiter}
series [block! hash!] dlm [string! char! bitset! any-word! any-block!] /local s num
][
num: either any-block? dlm [length? dlm] [1]
dlm: either any-word? dlm [to-block to-lit-word dlm] [dlm]
parse series [collect any [copy s [to dlm | to end] keep (s) num skip]]
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment