Guest User

Untitled

a guest
Jul 21st, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. Red []
  2.  
  3. idiom: [ [a (x: b) | reset (x: c)] x | reset d ] ; 1
  4. impl: [ a then b | reset c | reset d ] ; 2
  5. ;impl: [ a b | reset c | reset d ] ; 2
  6. ;impl: [ (f: yes) a (f: no) b | reset if (f) c | reset d ] ; 1
  7. ;impl: [ a b | reset not a c | reset d ] ; 3
  8. ;impl: [ not a c | reset a b | reset d ] ; 3
  9. ;impl: [ [a fail b] | reset c | reset d ] ; 2, nightly build only
  10. ;impl: [ p: a [b | :p reset d |] | reset c | reset d ] ; 1
  11.  
  12. y: [] n: [not []]
  13. side-eff: []
  14. inp-adv: []
  15. reset: [(clear inp-adv)]
  16. ptrn: func ['w] [ copy/deep reduce [
  17. reduce [to-paren compose [append side-eff (to-lit-word w)] 'n]
  18. reduce [to-paren compose [append side-eff (to-lit-word w)] to-paren compose [append inp-adv (to-lit-word w)] 'y]
  19. ] ]
  20. ? idiom
  21. ? impl
  22. print "Results:^/a b c d ^-[input advanced by] [side effects produced by] ..."
  23. foreach a ptrn a [
  24. foreach b ptrn b [
  25. foreach c ptrn c [
  26. foreach d ptrn d [
  27. set [a? b? c? d?] collect [foreach w [a b c d] [keep last get w]]
  28.  
  29. parse [1] impl
  30. prin [a? b? c? d? pad reduce ["^-impl>" mold inp-adv mold side-eff] 25]
  31. clear side-eff clear inp-adv
  32.  
  33. parse [1] idiom
  34. print ["idiom>" mold inp-adv mold side-eff]
  35. clear side-eff clear inp-adv
  36. ]]]]
Add Comment
Please, Sign In to add comment