Skip to content

Instantly share code, notes, and snippets.

@nedzadarek
Last active June 21, 2019 14:53
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 nedzadarek/126da5fa8cb92a9ce4b9e2665c17817b to your computer and use it in GitHub Desktop.
Save nedzadarek/126da5fa8cb92a9ce4b9e2665c17817b to your computer and use it in GitHub Desktop.
rejoin using mold
rejoin*: func ["Reduces and joins a block of values."
block [block!] "Values to reduce and join"
][
if empty? block: reduce block [return block]
append either (series? first block) [copy first block] [
mold first block
] next block]
some_word: "foo:"
word: to-word "some_word"
lit-word: to-lit-word "some_lit-word"
path: [to[something 42]]
path1: to-path [path to something]
lit-path: to-lit-path [lit path to something]
string: "str"
tag: <tag>
file: %file
bl: [a b c]
probe rejoin* [
word
":foo:"
]
"some_word:foo:"
; "some_word:foo:"
probe rejoin* [
'word
":foo:"
]
"word:foo:"
; "word:foo:"
probe rejoin* [
lit-word
":foo:"
]
"'some_lit-word:foo:"
; "'some_lit-word:foo:"
probe rejoin* [
lit-word
":foo:"
]
"'some_lit-word:foo:"
; "'some_lit-word:foo:"
probe rejoin* [
path1
":foo:"
]
path/to/something/":foo:"
; path/to/something/":foo:"
probe rejoin* [
lit-path
":foo:"
]
'lit/path/to/something/":foo:"
; 'lit/path/to/something/":foo:"
probe rejoin* [
string
":foo:"
]
"str:foo:"
; "str:foo:"
probe rejoin* [
tag
":foo:"
]
<tag:foo:>
; <tag:foo:>
probe rejoin* [
file
":foo:"
]
%file:foo:
; %file:foo:
probe rejoin* [
bl
":foo:"
]
[a b c ":foo:"]
; [a b c ":foo:"]
rejoin* [#foo 3]
; "#foo3"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment