Skip to content

Instantly share code, notes, and snippets.

@maximvl
Created August 5, 2016 01:00
Show Gist options
  • Save maximvl/6bcf182a105ee9443118248255f0fab5 to your computer and use it in GitHub Desktop.
Save maximvl/6bcf182a105ee9443118248255f0fab5 to your computer and use it in GitHub Desktop.
REBOL []
find-until: function [series test] [res] [
res: copy []
forall series [
either not test first series [
append res first series
] [
break/return res
]
]
]
get-args: function [a] [args-block] [
find-until first get a :refinement?
]
describe: function [block] [v args stack args-count tmp] [
block: reverse block
stack: []
forall block [
v: first block
either all [word! = type? v value? v op? get v] [
block: next block
tmp: first stack
remove stack
insert/only stack append append append copy [] first block v tmp
] [
either all [word! = type? 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 copy [] v args
] [
either word! = type? 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