Created
July 21, 2018 20:53
-
-
Save hiiamboris/cb357a315e646044ef361f7109b9928c to your computer and use it in GitHub Desktop.
Test of the `then` keyword
This file contains 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 [] | |
idiom: [ [a (x: b) | reset (x: c)] x | reset d ] ; 1 | |
impl: [ a then b | reset c | reset d ] ; 2 | |
;impl: [ a b | reset c | reset d ] ; 2 | |
;impl: [ (f: yes) a (f: no) b | reset if (f) c | reset d ] ; 1 | |
;impl: [ a b | reset not a c | reset d ] ; 3 | |
;impl: [ not a c | reset a b | reset d ] ; 3 | |
;impl: [ [a fail b] | reset c | reset d ] ; 2, nightly build only | |
;impl: [ p: a [b | :p reset d |] | reset c | reset d ] ; 1 | |
y: [] n: [not []] | |
side-eff: [] | |
inp-adv: [] | |
reset: [(clear inp-adv)] | |
ptrn: func ['w] [ copy/deep reduce [ | |
reduce [to-paren compose [append side-eff (to-lit-word w)] 'n] | |
reduce [to-paren compose [append side-eff (to-lit-word w)] to-paren compose [append inp-adv (to-lit-word w)] 'y] | |
] ] | |
? idiom | |
? impl | |
print "Results:^/a b c d ^-[input advanced by] [side effects produced by] ..." | |
foreach a ptrn a [ | |
foreach b ptrn b [ | |
foreach c ptrn c [ | |
foreach d ptrn d [ | |
set [a? b? c? d?] collect [foreach w [a b c d] [keep last get w]] | |
parse [1] impl | |
prin [a? b? c? d? pad reduce ["^-impl>" mold inp-adv mold side-eff] 25] | |
clear side-eff clear inp-adv | |
parse [1] idiom | |
print ["idiom>" mold inp-adv mold side-eff] | |
clear side-eff clear inp-adv | |
]]]] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment