Advertisement
Guest User

Untitled

a guest
Apr 29th, 2016
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.04 KB | None | 0 0
  1. : There is probably a mistake in here...
  2.  
  3. : Macroexpanded prod in FSB3 with %-comprehensions:
  4.  
  5. : Keep in mind that [] are *-loops in this language.
  6.  
  7. : prod : ... X Y -> ... {(x, y) for x in X, y in Y}
  8. prod:%[{~/~/>~{~/~/~/{%[{~/~/>~{~/~/~/>{~/~/>~~{{~/~/>/{~/~/>/{~/~/~/>{{~/~/>/{~/~/>/{{~/~/>/{~/~/>/~{{~/~/>/{~/~/>/]{~/~/>_]{~/~/>_
  9.  
  10. Conversion of %-comprehensions:
  11.  
  12. %[(code)] --> {{~/~/>[Z(code){{~/~/~/>{~/~/~/>[Z~{{~/~/>/{~/~/>/{~/~/~/>{~/~/~/>{~/~/>/{~/~/>]_{~/~/>]_
  13.  
  14. : prod : ... X Y -> ... {(x, y) for x in X, y in Y}
  15. prod: {{~/~/>[Z{~/~/>~{~/~/~/{{{~/~/>[Z{~/~/>~{~/~/~/>{~/~/>~~{{~/~/>/{~/~/>/{~/~/~/>{{~/~/>/{~/~/>/{{~/~/>/{~/~/>/~{{~/~/>/{~/~/>/{{~/~/~/>{~/~/~/>[Z~{{~/~/>/{~/~/>/{~/~/~/>{~/~/~/>{~/~/>/{~/~/>]_{~/~/>]_{~/~/>_{{~/~/~/>{~/~/~/>[Z~{{~/~/>/{~/~/>/{~/~/~/>{~/~/~/>{~/~/>/{~/~/>]_{~/~/>]_{~/~/>_
  16.  
  17. : lists : ... X -> ... {l : l is a #X-long linked list of either {x} or {} for x ∈ X using some consistent order}
  18. lists:{~/{~/~/>[Z~{{~/~/>/{~/~/>/{~/~/~/>{~/~/>{{{~/~/>/{~/~/>/{~/~/>{{~/~/>[Z{~/~/>~{~/~/~/{{{~/~/>[Z{~/~/>~{~/~/~/>{~/~/>~~{{~/~/>/{~/~/>/{~/~/~/>{{~/~/>/{~/~/>/{{~/~/>/{~/~/>/~{{~/~/>/{~/~/>/{{~/~/~/>{~/~/~/>[Z~{{~/~/>/{~/~/>/{~/~/~/>{~/~/~/>{~/~/>/{~/~/>]_{~/~/>]_{~/~/>_{{~/~/~/>{~/~/~/>[Z~{{~/~/>/{~/~/>/{~/~/~/>{~/~/~/>{~/~/>/{~/~/>]_{~/~/>]_{~/~/>_{~/~/>]_
  19.  
  20. : recall [(then),(else)] -> ~{=~[__(else){{{]__~[_(then){{]__
  21.  
  22. : removeEmpty : ... x y z w -> ... a b c which are three of x y z w with an {} removed. Loops forever if no {}.
  23. : removeEmpty:[{~/~/~/~/>]_
  24.  
  25. : dup2 in FSB3
  26. : dup2 : ... X Y -> X Y X Y
  27. : dup2 : {~/~/>~{~/~/~/>{~/~/~/>~{~/~/~/>
  28.  
  29. : not in FSB3
  30. : not:{=
  31.  
  32. : magic : ... a b c -> ... returns h t where [h, h, t] is some permutation of a b c. Loops forever if no two are equal.
  33. : magic:{~/[_{~/~/~/>(dup2)=(not)]_{~/~/>
  34.  
  35. : magic:{~/[_{~/~/~/>{~/~/>~{~/~/~/>{~/~/~/>~{~/~/~/>={=]_{~/~/>
  36.  
  37. : split : ... (h, t) -> ... h t
  38. : This is surprisingly complicated, because we've given up our set operations. We use a bunch of Z's and movement operators to get
  39. : ... (h, t) -> <h t h {} in some order>
  40. : then we use removeEmpty to remove an {} and magic to get h t in the right order.
  41. split:Z{~/~/>Z{~/~/>_~{=~[___~{{{]__~[_{{]__~Z{~/~/>Z{~/~/~/>{~/~/~/>~Z{~/~/>Z(removeEmpty)(magic)
  42.  
  43. split:Z{~/~/>Z{~/~/>_~{=~[___~{{{]__~[_{{]__~Z{~/~/>Z{~/~/~/>{~/~/~/>~Z{~/~/>Z[{~/~/~/~/>]_{~/[_{~/~/~/>{~/~/>~{~/~/~/>{~/~/~/>~{~/~/~/>={=]_{~/~/>
  44.  
  45. 1st:(split)_
  46. 2nd:(split){~/~/>_
  47.  
  48. : union
  49. union:[Z{~/~/~/>{~/~/~/>{~/~/>/{~/~/>]_
  50.  
  51.  
  52. listToSet:{{~/~/>[~(1st){~/~/>(2nd){~/~/}>[(union),_]{~/~/>]_
  53. listToSet:{{~/~/>[~Z{~/~/>Z{~/~/>_~{=~[___~{{{]__~[_{{]__~Z{~/~/>Z{~/~/~/>{~/~/~/>~Z{~/~/>Z[{~/~/~/~/>]_{~/[_{~/~/~/>{~/~/>~{~/~/~/>{~/~/~/>~{~/~/~/>={=]_{~/~/>_{~/~/>Z{~/~/>Z{~/~/>_~{=~[___~{{{]__~[_{{]__~Z{~/~/>Z{~/~/~/>{~/~/~/>~Z{~/~/>Z[{~/~/~/~/>]_{~/[_{~/~/~/>{~/~/>~{~/~/~/>{~/~/~/>~{~/~/~/>={=]_{~/~/>{~/~/>_{~/~/}>~{=~[___{{{]__~[_[Z{~/~/~/>{~/~/~/>{~/~/>/{~/~/>]_{{]__{~/~/>]_
  54. : 375 characters long!
  55.  
  56. %[(code)] --> {{~/~/>[Z(code){{~/~/~/>{~/~/~/>[Z~{{~/~/>/{~/~/>/{~/~/~/>{~/~/~/>{~/~/>/{~/~/>]_{~/~/>]_
  57.  
  58. powerset:(lists)%[(listtoset)~+] in regular SetBang
  59. powerset:(lists)%[(listtoset){{~/~/>/] in stripped-down SetBang
  60. powerset:(lists){{~/~/>[Z(listtoset){{~/~/>/{{~/~/~/>{~/~/~/>[Z~{{~/~/>/{~/~/>/{~/~/~/>{~/~/~/>{~/~/>/{~/~/>]_{~/~/>]_
  61. powerset:{~/{~/~/>[Z~{{~/~/>/{~/~/>/{~/~/~/>{~/~/>{{{~/~/>/{~/~/>/{~/~/>{{~/~/>[Z{~/~/>~{~/~/~/{{{~/~/>[Z{~/~/>~{~/~/~/>{~/~/>~~{{~/~/>/{~/~/>/{~/~/~/>{{~/~/>/{~/~/>/{{~/~/>/{~/~/>/~{{~/~/>/{~/~/>/{{~/~/~/>{~/~/~/>[Z~{{~/~/>/{~/~/>/{~/~/~/>{~/~/~/>{~/~/>/{~/~/>]_{~/~/>]_{~/~/>_{{~/~/~/>{~/~/~/>[Z~{{~/~/>/{~/~/>/{~/~/~/>{~/~/~/>{~/~/>/{~/~/>]_{~/~/>]_{~/~/>_{~/~/>]_{{~/~/>[Z{{~/~/>[~Z{~/~/>Z{~/~/>_~{=~[___~{{{]__~[_{{]__~Z{~/~/>Z{~/~/~/>{~/~/~/>~Z{~/~/>Z[{~/~/~/~/>]_{~/[_{~/~/~/>{~/~/>~{~/~/~/>{~/~/~/>~{~/~/~/>={=]_{~/~/>_{~/~/>Z{~/~/>Z{~/~/>_~{=~[___~{{{]__~[_{{]__~Z{~/~/>Z{~/~/~/>{~/~/~/>~Z{~/~/>Z[{~/~/~/~/>]_{~/[_{~/~/~/>{~/~/>~{~/~/~/>{~/~/~/>~{~/~/~/>={=]_{~/~/>{~/~/>_{~/~/}>~{=~[___{{{]__~[_[Z{~/~/~/>{~/~/~/>{~/~/>/{~/~/>]_{{]__{~/~/>]_{{~/~/>/{{~/~/~/>{~/~/~/>[Z~{{~/~/>/{~/~/>/{~/~/~/>{~/~/~/>{~/~/>/{~/~/>]_{~/~/>]_
  62. : 824 characters long!
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement