Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save dockimbel/c1ee08dd520144f72b493e99d289945a to your computer and use it in GitHub Desktop.
Save dockimbel/c1ee08dd520144f72b493e99d289945a to your computer and use it in GitHub Desktop.
Red []
find-until: function [series test][
res: copy []
forall series [
either not test first series [
append res first series
] [
break/return res
]
]
]
get-args: function [a][
find-until spec-of get a :refinement?
]
describe: function [block][
block: reverse block
stack: []
forall block [
v: first block
either all [word? v value? v op? get v] [
block: next block
tmp: first stack
remove stack
insert/only stack append append append make paren! 4 first block v tmp
] [
either all [word? v value? v any-function? get v] [
args-count: length? get-args v
args: copy/part stack args-count
remove/part stack args-count
insert/only stack append append make paren! 4 v args
] [
;either word? v [
; insert/only stack to lit-word! v
;] [
insert/only stack v
;]
]
]
]
print mold reduce stack
]
;>describe [head reverse [1 2 3] help :reverse a]
;[[head [reverse [1 2 3]]] [help :reverse] a]
;>describe [insert stack append append append copy [] first block v tmp]
;[[insert 'stack [append [append [append [copy []] [first 'block]] 'v] 'tmp]]]
;>describe [1 + 1 at series 5 false and true]
;[[1 + 1] [at 'series 5] [false and true]]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment