Forked from maximvl/gist:6bcf182a105ee9443118248255f0fab5
Last active
August 5, 2016 01:18
-
-
Save dockimbel/c1ee08dd520144f72b493e99d289945a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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