fez-lisp 1.0.29 → 1.0.31

Sign up to get free protection for your applications and to get access to all the features.
package/README.md CHANGED
@@ -121,6 +121,28 @@ fez(
121
121
  )
122
122
  ```
123
123
 
124
+ Many logical operators
125
+
126
+ ```lisp
127
+ (let logic-a (lambda a b
128
+ (if (or (= b -1) (> a b)) "a"
129
+ (if (and (> b 2) (< a 4)) "b" "c"))))
130
+
131
+ ; De Morgan's First Law: ¬(P ∧ Q) is equivalent to (¬P ∨ ¬Q)
132
+ ; De Morgan's Second Law: ¬(P ∨ Q) is equivalent to (¬P ∧ ¬Q)
133
+ (let logic-b (lambda a b
134
+ ; Swapping the consequent with the alternative in the condition by using (unless) instead of (if)
135
+ ; The condition (or (= b -1) (> a b)) has been changed to (and (not (= b -1)) (not (> a b))), applying De Morgan's First Law.
136
+ ; The condition (and (> b 2) (< a 4)) has been changed to (or (not (> b 2)) (not (< a 4))), applying De Morgan's Second Law.
137
+ (unless (and (not (= b -1)) (not (> a b))) "a"
138
+ (unless (or (not (> b 2)) (not (< a 4))) "b" "c"))))
139
+
140
+ (assert
141
+ (case "a=0 b=-1" (logic-a 0 -1) (logic-b 0 -1))
142
+ (case "a=1 b=3" (logic-a 1 3) (logic-b 1 3))
143
+ (case "a=1 b=2" (logic-a 1 2) (logic-b 1 2)))
144
+ ```
145
+
124
146
  Tail Call Optimization:
125
147
 
126
148
  There are no loop constructs (like a "for" or "while" loop in other languages).
package/lib/baked/std.js CHANGED
@@ -1 +1 @@
1
- export default [[["f","let"],["w","math:E"],["a",2.718281828459045]],[["f","let"],["w","math:PI"],["a",3.141592653589793]],[["f","let*"],["w","array:for"],[["f","lambda"],["w","arr"],["w","callback"],[["f","when"],[["f","length"],["w","arr"]],[["f","do"],[["f","callback"],[["f","car"],["w","arr"]]],[["f","array:for"],[["f","cdr"],["w","arr"]],["w","callback"]]]]]],[["f","let"],["w","array:map"],[["f","lambda"],["w","arr"],["w","callback"],[["f","do"],[["f","let*"],["w","iterate"],[["f","lambda"],["w","arr"],["w","out"],[["f","if"],[["f","length"],["w","arr"]],[["f","iterate"],[["f","cdr"],["w","arr"]],[["f","array:merge!"],["w","out"],[["f","array"],[["f","callback"],[["f","car"],["w","arr"]]]]]],["w","out"]]]],[["f","iterate"],["w","arr"],[]]]]],[["f","let"],["w","array:select"],[["f","lambda"],["w","arr"],["w","callback"],[["f","do"],[["f","let*"],["w","iterate"],[["f","lambda"],["w","arr"],["w","out"],[["f","if"],[["f","length"],["w","arr"]],[["f","iterate"],[["f","cdr"],["w","arr"]],[["f","if"],[["f","callback"],[["f","car"],["w","arr"]]],[["f","array:merge!"],["w","out"],[["f","array"],[["f","car"],["w","arr"]]]],["w","out"]]],["w","out"]]]],[["f","iterate"],["w","arr"],[]]]]],[["f","let"],["w","array:exclude"],[["f","lambda"],["w","arr"],["w","callback"],[["f","do"],[["f","let*"],["w","iterate"],[["f","lambda"],["w","arr"],["w","out"],[["f","if"],[["f","length"],["w","arr"]],[["f","iterate"],[["f","cdr"],["w","arr"]],[["f","if"],[["f","not"],[["f","callback"],[["f","car"],["w","arr"]]]],[["f","array:merge!"],["w","out"],[["f","array"],[["f","car"],["w","arr"]]]],["w","out"]]],["w","out"]]]],[["f","iterate"],["w","arr"],[]]]]],[["f","let"],["w","array:fold"],[["f","lambda"],["w","arr"],["w","callback"],["w","initial"],[["f","do"],[["f","let*"],["w","iterate"],[["f","lambda"],["w","arr"],["w","out"],[["f","if"],[["f","length"],["w","arr"]],[["f","iterate"],[["f","cdr"],["w","arr"]],[["f","callback"],["w","out"],[["f","car"],["w","arr"]]]],["w","out"]]]],[["f","iterate"],["w","arr"],["w","initial"]]]]],[["f","let"],["w","array:every?"],[["f","lambda"],["w","arr"],["w","callback"],[["f","do"],[["f","let*"],["w","iterate"],[["f","lambda"],["w","arr"],[["f","if"],[["f","and"],[["f","length"],["w","arr"]],[["f","callback"],[["f","car"],["w","arr"]]]],[["f","iterate"],[["f","cdr"],["w","arr"]]],[["f","not"],[["f","length"],["w","arr"]]]]]],[["f","iterate"],["w","arr"]]]]],[["f","let"],["w","array:some?"],[["f","lambda"],["w","arr"],["w","callback"],[["f","do"],[["f","let*"],["w","iterate"],[["f","lambda"],["w","arr"],[["f","if"],[["f","and"],[["f","length"],["w","arr"]],[["f","not"],[["f","callback"],[["f","car"],["w","arr"]]]]],[["f","iterate"],[["f","cdr"],["w","arr"]]],[["f","type"],[["f","length"],["w","arr"]],["w","boolean"]]]]],[["f","iterate"],["w","arr"]]]]],[["f","let"],["w","array:find"],[["f","lambda"],["w","arr"],["w","callback"],[["f","do"],[["f","let*"],["w","iterate"],[["f","lambda"],["w","arr"],[["f","if"],[["f","length"],["w","arr"]],[["f","if"],[["f","callback"],[["f","car"],["w","arr"]]],[["f","car"],["w","arr"]],[["f","iterate"],[["f","cdr"],["w","arr"]]]],[]]]],[["f","iterate"],["w","arr"]]]]],[["f","let"],["w","array:has?"],[["f","lambda"],["w","arr"],["w","callback"],[["f","do"],[["f","let*"],["w","iterate"],[["f","lambda"],["w","arr"],[["f","when"],[["f","length"],["w","arr"]],[["f","if"],[["f","callback"],[["f","car"],["w","arr"]]],["a",1],[["f","iterate"],[["f","cdr"],["w","arr"]]]]]]],[["f","iterate"],["w","arr"]]]]],[["f","let"],["w","array:reverse"],[["f","lambda"],["w","arr"],[["f","do"],[["f","let*"],["w","iterate"],[["f","lambda"],["w","arr"],["w","out"],[["f","if"],[["f","length"],["w","arr"]],[["f","iterate"],[["f","cdr"],["w","arr"]],[["f","array:merge!"],[["f","array"],[["f","car"],["w","arr"]]],["w","out"]]],["w","out"]]]],[["f","iterate"],["w","arr"],[]]]]],[["f","let"],["w","math:range"],[["f","lambda"],["w","start"],["w","end"],[["f","do"],[["f","let*"],["w","iterate"],[["f","lambda"],["w","out"],["w","count"],[["f","if"],[["f","<="],["w","count"],["w","end"]],[["f","iterate"],[["f","array:merge!"],["w","out"],[["f","array"],["w","count"]]],[["f","+"],["w","count"],["a",1]]],["w","out"]]]],[["f","iterate"],[],["w","start"]]]]],[["f","let"],["w","math:sequence"],[["f","lambda"],["w","arr"],[["f","do"],[["f","let"],["w","end"],[["f","length"],["w","arr"]]],[["f","let*"],["w","iterate"],[["f","lambda"],["w","out"],["w","count"],[["f","if"],[["f","<"],[["f","length"],["w","out"]],["w","end"]],[["f","iterate"],[["f","array:merge!"],["w","out"],[["f","array"],["w","count"]]],[["f","+"],["w","count"],["a",1]]],["w","out"]]]],[["f","iterate"],[],["a",0]]]]],[["f","let"],["w","math:sequence-n"],[["f","lambda"],["w","n"],[["f","do"],[["f","let*"],["w","iterate"],[["f","lambda"],["w","out"],["w","count"],[["f","if"],[["f","<"],[["f","length"],["w","out"]],["w","n"]],[["f","iterate"],[["f","array:merge!"],["w","out"],[["f","array"],["w","count"]]],[["f","+"],["w","count"],["a",1]]],["w","out"]]]],[["f","iterate"],[],["a",0]]]]],[["f","let"],["w","array:unique"],[["f","lambda"],["w","arr"],[["f","pi"],[["f","let"],["w","sorted"],[["f","array:sort"],["w","arr"],[["f","safety"],["w","lambda"],["w","a"],["w","b"],[["f",">"],["w","a"],["w","b"]]]]],[["f","array:zip"],[["f","math:sequence"],["w","sorted"]]],[["f","array:select"],[["f","lambda"],["w","x"],[["f","or"],[["f","not"],[["f","let"],["w","index"],[["f","car"],[["f","cdr"],["w","x"]]]]],[["f","not"],[["f","="],[["f","array:get"],["w","sorted"],[["f","-"],["w","index"],["a",1]]],[["f","array:get"],["w","sorted"],["w","index"]]]]]]],[["f","array:map"],["w","car"]]]]],[["f","let"],["w","array:for-range"],[["f","lambda"],["w","start"],["w","end"],["w","callback"],[["f","do"],[["f","let*"],["w","iterate"],[["f","lambda"],["w","i"],[["f","when"],[["f","<"],["w","i"],["w","end"]],[["f","do"],[["f","callback"],["w","i"]],[["f","iterate"],[["f","+"],["w","i"],["a",1]]]]]]],[["f","iterate"],["w","start"]]]]],[["f","let"],["w","array:traverse"],[["f","lambda"],["w","x"],["w","callback"],[["f","if"],[["f","atom?"],["w","x"]],[["f","callback"],["w","x"]],[["f","iterate"],["w","x"],[["f","lambda"],["w","y"],[["f","array:traverse"],["w","y"],["w","callback"]]]]]]],[["f","let"],["w","math:summation"],[["f","lambda"],["w","arr"],[["f","array:fold"],["w","arr"],[["f","safety"],["w","lambda"],["w","a"],["w","b"],[["f","+"],["w","a"],["w","b"]]],[["f","+"]]]]],[["f","let"],["w","math:product"],[["f","lambda"],["w","arr"],[["f","array:fold"],["w","arr"],[["f","safety"],["w","lambda"],["w","a"],["w","b"],[["f","*"],["w","a"],["w","b"]]],[["f","*"]]]]],[["f","let"],["w","math:maximum"],[["f","lambda"],["w","arr"],[["f","array:fold"],["w","arr"],[["f","safety"],["w","lambda"],["w","a"],["w","b"],[["f","if"],[["f",">"],["w","a"],["w","b"]],["w","a"],["w","b"]]],[["f","car"],["w","arr"]]]]],[["f","let"],["w","math:minimum"],[["f","lambda"],["w","arr"],[["f","array:fold"],["w","arr"],[["f","safety"],["w","lambda"],["w","a"],["w","b"],[["f","if"],[["f","<"],["w","a"],["w","b"]],["w","a"],["w","b"]]],[["f","car"],["w","arr"]]]]],[["f","let"],["w","math:max"],[["f","lambda"],["w","a"],["w","b"],[["f","if"],[["f",">"],["w","a"],["w","b"]],["w","a"],["w","b"]]]],[["f","let"],["w","math:min"],[["f","lambda"],["w","a"],["w","b"],[["f","if"],[["f","<"],["w","a"],["w","b"]],["w","a"],["w","b"]]]],[["f","let"],["w","array:count-of"],[["f","lambda"],["w","arr"],["w","callback"],[["f","pi"],["w","arr"],[["f","array:select"],["w","callback"]],[["f","length"]]]]],[["f","let"],["w","math:increment"],[["f","safety"],["w","lambda"],["w","i"],[["f","+"],["w","i"],["a",1]]]],[["f","let"],["w","math:floor"],[["f","safety"],["w","lambda"],["w","n"],[["f","|"],["w","n"],["a",0]]]],[["f","let"],["w","math:round"],[["f","safety"],["w","lambda"],["w","n"],[["f","|"],[["f","+"],["w","n"],["a",0.5]],["a",0]]]],[["f","let"],["w","array:empty?"],[["f","safety"],["w","lambda"],["w","arr"],[["f","not"],[["f","length"],["w","arr"]]]]],[["f","let"],["w","array:empty!"],[["f","safety"],["w","lambda"],["w","arr"],[["f","do"],[["f","let*"],["w","iterate"],[["f","lambda"],[["f","if"],[["f","length"],["w","arr"]],[["f","do"],[["f","array:set!"],["w","arr"],["a",-1]],[["f","iterate"]]],["w","arr"]]]],[["f","iterate"]]]]],[["f","let"],["w","array:in-bounds?"],[["f","safety"],["w","lambda"],["w","arr"],["w","index"],[["f","and"],[["f","<"],["w","index"],[["f","length"],["w","arr"]]],[["f",">="],["w","index"],["a",0]]]]],[["f","let"],["w","math:largest-power"],[["f","safety"],["w","lambda"],["w","N"],[["f","do"],[["f","let"],["w","N1"],[["f","|"],["w","N"],[["f",">>"],["w","N"],["a",1]]]],[["f","let"],["w","N2"],[["f","|"],["w","N1"],[["f",">>"],["w","N1"],["a",2]]]],[["f","let"],["w","N3"],[["f","|"],["w","N2"],[["f",">>"],["w","N2"],["a",4]]]],[["f","let"],["w","N4"],[["f","|"],["w","N3"],[["f",">>"],["w","N3"],["a",8]]]],[["f",">>"],[["f","+"],["w","N4"],["a",1]],["a",1]]]]],[["f","let"],["w","math:set-bit"],[["f","safety"],["w","lambda"],["w","n"],["w","bit"],[["f","|"],["w","n"],[["f","<<"],["a",1],["w","bit"]]]]],[["f","let"],["w","math:clear-bit"],[["f","safety"],["w","lambda"],["w","n"],["w","bit"],[["f","&"],["w","n"],[["f","~"],[["f","<<"],["a",1],["w","bit"]]]]]],[["f","let"],["w","math:odd-bit?"],[["f","safety"],["w","lambda"],["w","n"],[["f","="],[["f","&"],["w","n"],["a",1]],["a",1]]]],[["f","let"],["w","math:average-bit"],[["f","safety"],["w","lambda"],["w","a"],["w","b"],[["f",">>"],[["f","+"],["w","a"],["w","b"]],["a",1]]]],[["f","let"],["w","math:toggle-bit"],[["f","safety"],["w","lambda"],["w","n"],["w","a"],["w","b"],[["f","^"],["w","a"],["w","b"],["w","n"]]]],[["f","let"],["w","math:same-sign-bit?"],[["f","safety"],["w","lambda"],["w","a"],["w","b"],[["f",">="],[["f","^"],["w","a"],["w","b"]],["a",0]]]],[["f","let"],["w","math:max-bit"],[["f","safety"],["w","lambda"],["w","a"],["w","b"],[["f","-"],["w","a"],[["f","&"],[["f","-"],["w","a"],["w","b"]],[["f",">>"],[["f","-"],["w","a"],["w","b"]],["a",31]]]]]],[["f","let"],["w","math:min-bit"],[["f","safety"],["w","lambda"],["w","a"],["w","b"],[["f","-"],["w","a"],[["f","&"],[["f","-"],["w","a"],["w","b"]],[["f",">>"],[["f","-"],["w","b"],["w","a"]],["a",31]]]]]],[["f","let"],["w","math:modulo-bit"],[["f","safety"],["w","lambda"],["w","numerator"],["w","divisor"],[["f","&"],["w","numerator"],[["f","-"],["w","divisor"],["a",1]]]]],[["f","let"],["w","math:n-one-bit?"],[["f","safety"],["w","lambda"],["w","N"],["w","nth"],[["f","type"],[["f","&"],["w","N"],[["f","<<"],["a",1],["w","nth"]]],["w","boolean"]]]],[["f","let"],["w","cast:string->chars"],[["f","safety"],["w","lambda"],["w","str"],[["f","type"],["w","str"],["w","array"]]]],[["f","let"],["w","cast:chars->string"],[["f","lambda"],["w","arr"],[["f","array:fold"],["w","arr"],[["f","safety"],["w","lambda"],["w","a"],["w","x"],[["f","string:merge"],["w","a"],[["f","type"],["w","x"],["w","string"]]]],["a",""]]]],[["f","let"],["w","cast:string->number"],[["f","safety"],["w","lambda"],["w","str"],[["f","type"],["w","str"],["w","number"]]]],[["f","let"],["w","cast:number->string"],[["f","safety"],["w","lambda"],["w","n"],[["f","type"],["w","n"],["w","string"]]]],[["f","let"],["w","cast:strings->numbers"],[["f","lambda"],["w","arr"],[["f","array:map"],["w","arr"],[["f","safety"],["w","lambda"],["w","x"],[["f","type"],["w","x"],["w","number"]]]]]],[["f","let"],["w","cast:numbers->strings"],[["f","lambda"],["w","arr"],[["f","array:map"],["w","arr"],[["f","safety"],["w","lambda"],["w","x"],[["f","type"],["w","x"],["w","string"]]]]]],[["f","let"],["w","cast:string->char-codes"],[["f","lambda"],["w","str"],[["f","pi"],["w","str"],[["f","type"],["w","array"]],[["f","array:map"],[["f","safety"],["w","lambda"],["w","x"],[["f","type"],["w","x"],["w","char-code"]]]]]]],[["f","let"],["w","cast:chars->char-codes"],[["f","lambda"],["w","arr"],[["f","pi"],["w","arr"],[["f","array:map"],[["f","safety"],["w","lambda"],["w","x"],[["f","type"],["w","x"],["w","char-code"]]]]]]],[["f","let"],["w","cast:chars->numbers"],[["f","lambda"],["w","arr"],[["f","pi"],["w","arr"],[["f","array:map"],[["f","safety"],["w","lambda"],["w","x"],[["f","type"],["w","x"],["w","number"]]]]]]],[["f","let"],["w","cast:char->number"],[["f","safety"],["w","lambda"],["w","ch"],[["f","type"],["w","ch"],["w","number"]]]],[["f","let"],["w","cast:char->char-code"],[["f","safety"],["w","lambda"],["w","ch"],[["f","type"],["w","ch"],["w","char-code"]]]],[["f","let"],["w","cast:char-code->char"],[["f","safety"],["w","lambda"],["w","ch"],[["f","type"],["w","ch"],["w","char"]]]],[["f","let"],["w","cast:char-codes->chars"],[["f","lambda"],["w","arr"],[["f","pi"],["w","arr"],[["f","array:map"],[["f","safety"],["w","lambda"],["w","x"],[["f","type"],["w","x"],["w","char"]]]]]]],[["f","let"],["w","cast:char-codes->string"],[["f","lambda"],["w","arr"],[["f","pi"],["w","arr"],[["f","array:map"],[["f","safety"],["w","lambda"],["w","x"],[["f","type"],["w","x"],["w","char"]]]],[["f","cast:chars->string"]]]]],[["f","let"],["w","math:square"],[["f","safety"],["w","lambda"],["w","x"],[["f","*"],["w","x"],["w","x"]]]],[["f","let"],["w","math:power"],[["f","lambda"],["w","base"],["w","exp"],[["f","if"],[["f","<"],["w","exp"],["a",0]],[["f","if"],[["f","="],["w","base"],["a",0]],[["f","throw"],["a","Attempting to divide by 0 in (math:power)"]],[["f","/"],[["f","*"],["w","base"],[["f","math:power"],["w","base"],[["f","-"],[["f","*"],["w","exp"],["a",-1]],["a",1]]]]]],[["f","cond"],[["f","="],["w","exp"],["a",0]],["a",1],[["f","="],["w","exp"],["a",1]],["w","base"],[["f","*"]],[["f","*"],["w","base"],[["f","math:power"],["w","base"],[["f","-"],["w","exp"],["a",1]]]]]]]],[["f","let"],["w","math:greatest-common-divisor"],[["f","lambda"],["w","a"],["w","b"],[["f","do"],[["f","let*"],["w","gcd"],[["f","lambda"],["w","a"],["w","b"],[["f","if"],[["f","="],["w","b"],["a",0]],["w","a"],[["f","gcd"],["w","b"],[["f","mod"],["w","a"],["w","b"]]]]]],[["f","gcd"],["w","a"],["w","b"]]]]],[["f","let"],["w","math:least-common-divisor"],[["f","lambda"],["w","a"],["w","b"],[["f","*"],["w","a"],["w","b"],[["f","/"],[["f","math:greatest-common-divisor"],["w","a"],["w","b"]]]]]],[["f","let"],["w","math:sqrt"],[["f","lambda"],["w","x"],[["f","do"],[["f","let"],["w","is-good-enough"],[["f","lambda"],["w","g"],["w","x"],[["f","<"],[["f","math:abs"],[["f","-"],[["f","math:square"],["w","g"]],["w","x"]]],["a",0.01]]]],[["f","let"],["w","improve-guess"],[["f","lambda"],["w","g"],["w","x"],[["f","math:average"],["w","g"],[["f","*"],["w","x"],[["f","/"],["w","g"]]]]]],[["f","let*"],["w","math:sqrt-iter"],[["f","lambda"],["w","g"],["w","x"],[["f","if"],[["f","is-good-enough"],["w","g"],["w","x"]],["w","g"],[["f","math:sqrt-iter"],[["f","improve-guess"],["w","g"],["w","x"]],["w","x"]]]]],[["f","math:sqrt-iter"],["a",1],["w","x"]]]]],[["f","let"],["w","math:circumference"],[["f","lambda"],["w","radius"],[["f","*"],["w","math:PI"],[["f","*"],["w","radius"],["a",2]]]]],[["f","let"],["w","math:hypotenuse"],[["f","lambda"],["w","a"],["w","b"],[["f","math:sqrt"],[["f","+"],[["f","*"],["w","a"],["w","a"]],[["f","*"],["w","b"],["w","b"]]]]]],[["f","let"],["w","math:abs"],[["f","safety"],["w","lambda"],["w","n"],[["f","-"],[["f","^"],["w","n"],[["f",">>"],["w","n"],["a",31]]],[["f",">>"],["w","n"],["a",31]]]]],[["f","let"],["w","math:nth-digit"],[["f","lambda"],["w","digit"],["w","n"],[["f","|"],[["f","mod"],[["f","/"],["w","digit"],[["f","math:power"],["a",10],[["f","-"],["w","n"],["a",1]]]],["a",10]],["a",0.5]]]],[["f","let"],["w","math:normalize"],[["f","safety"],["w","lambda"],["w","value"],["w","math:min"],["w","math:max"],[["f","*"],[["f","-"],["w","value"],["w","math:min"]],[["f","/"],[["f","-"],["w","math:max"],["w","math:min"]]]]]],[["f","let"],["w","math:linear-interpolation"],[["f","safety"],["w","lambda"],["w","a"],["w","b"],["w","n"],[["f","+"],[["f","*"],[["f","-"],["a",1],["w","n"]],["w","a"]],[["f","*"],["w","n"],["w","b"]]]]],[["f","let"],["w","math:gauss-sum"],[["f","safety"],["w","lambda"],["w","n"],[["f","*"],["w","n"],[["f","+"],["w","n"],["a",1]],["a",0.5]]]],[["f","let"],["w","math:gauss-sum-sequance"],[["f","safety"],["w","lambda"],["w","a"],["w","b"],[["f","*"],[["f","+"],["w","a"],["w","b"]],[["f","+"],[["f","-"],["w","b"],["w","a"]],["a",1]],["a",0.5]]]],[["f","let"],["w","math:clamp"],[["f","safety"],["w","lambda"],["w","x"],["w","limit"],[["f","if"],[["f",">"],["w","x"],["w","limit"]],["w","limit"],["w","x"]]]],[["f","let"],["w","math:odd?"],[["f","safety"],["w","lambda"],["w","x"],[["f","="],[["f","mod"],["w","x"],["a",2]],["a",1]]]],[["f","let"],["w","math:even?"],[["f","safety"],["w","lambda"],["w","x"],[["f","="],[["f","mod"],["w","x"],["a",2]],["a",0]]]],[["f","let"],["w","math:sign"],[["f","safety"],["w","lambda"],["w","n"],[["f","if"],[["f","<"],["w","n"],["a",0]],["a",-1],["a",1]]]],[["f","let"],["w","math:radians"],[["f","lambda"],["w","deg"],[["f","*"],["w","deg"],["w","math:PI"],[["f","/"],["a",180]]]]],[["f","let"],["w","math:average"],[["f","safety"],["w","lambda"],["w","x"],["w","y"],[["f","*"],[["f","+"],["w","x"],["w","y"]],["a",0.5]]]],[["f","let"],["w","math:euclidean-mod"],[["f","safety"],["w","lambda"],["w","a"],["w","b"],[["f","mod"],[["f","+"],[["f","mod"],["w","a"],["w","b"]],["w","b"]],["w","b"]]]],[["f","let"],["w","math:euclidean-distance"],[["f","lambda"],["w","x1"],["w","y1"],["w","x2"],["w","y2"],[["f","do"],[["f","let"],["w","a"],[["f","-"],["w","x1"],["w","x2"]]],[["f","let"],["w","b"],[["f","-"],["w","y1"],["w","y2"]]],[["f","math:sqrt"],[["f","+"],[["f","*"],["w","a"],["w","a"]],[["f","*"],["w","b"],["w","b"]]]]]]],[["f","let"],["w","math:manhattan-distance"],[["f","lambda"],["w","x1"],["w","y1"],["w","x2"],["w","y2"],[["f","+"],[["f","math:abs"],[["f","-"],["w","x2"],["w","x1"]]],[["f","math:abs"],[["f","-"],["w","y2"],["w","y1"]]]]]],[["f","let"],["w","math:positive?"],[["f","safety"],["w","lambda"],["w","num"],[["f",">"],["w","num"],["a",0]]]],[["f","let"],["w","math:negative?"],[["f","safety"],["w","lambda"],["w","num"],[["f","<"],["w","num"],["a",0]]]],[["f","let"],["w","math:zero?"],[["f","safety"],["w","lambda"],["w","num"],[["f","="],["w","num"],["a",0]]]],[["f","let"],["w","math:divisible?"],[["f","safety"],["w","lambda"],["w","a"],["w","b"],[["f","="],[["f","mod"],["w","a"],["w","b"]],["a",0]]]],[["f","let"],["w","math:ascending?"],[["f","lambda"],["w","a"],["w","b"],[["f",">"],["w","a"],["w","b"]]]],[["f","let"],["w","math:descending?"],[["f","lambda"],["w","a"],["w","b"],[["f","<"],["w","a"],["w","b"]]]],[["f","let"],["w","math:prime?"],[["f","lambda"],["w","n"],[["f","cond"],[["f","="],["w","n"],["a",1]],["a",0],[["f","<"],["w","n"],["a",0]],["a",0],[["f","*"]],[["f","do"],[["f","let*"],["w","iter"],[["f","lambda"],["w","i"],["w","end"],[["f","do"],[["f","let"],["w","is-prime"],[["f","not"],[["f","="],[["f","mod"],["w","n"],["w","i"]],["a",0]]]],[["f","if"],[["f","and"],[["f","<="],["w","i"],["w","end"]],["w","is-prime"]],[["f","iter"],[["f","+"],["w","i"],["a",1]],["w","end"]],["w","is-prime"]]]]],[["f","or"],[["f","="],["w","n"],["a",2]],[["f","iter"],["a",2],[["f","math:sqrt"],["w","n"]]]]]]]],[["f","let"],["w","array:slice"],[["f","lambda"],["w","arr"],["w","start"],["w","end"],[["f","do"],[["f","let"],["w","bounds"],[["f","-"],["w","end"],["w","start"]]],[["f","let*"],["w","iterate"],[["f","lambda"],["w","i"],["w","out"],[["f","if"],[["f","<"],["w","i"],["w","bounds"]],[["f","iterate"],[["f","+"],["w","i"],["a",1]],[["f","array:merge!"],["w","out"],[["f","array"],[["f","array:get"],["w","arr"],[["f","+"],["w","start"],["w","i"]]]]]],["w","out"]]]],[["f","iterate"],["a",0],[]]]]],[["f","let"],["w","array:binary-search"],[["f","lambda"],["w","arr"],["w","target"],[["f","do"],[["f","let*"],["w","search"],[["f","lambda"],["w","arr"],["w","target"],["w","start"],["w","end"],[["f","do"],[["f","when"],[["f","<="],["w","start"],["w","end"]],[["f","do"],[["f","let"],["w","index"],[["f","math:floor"],[["f","*"],[["f","+"],["w","start"],["w","end"]],["a",0.5]]]],[["f","let"],["w","current"],[["f","array:get"],["w","arr"],["w","index"]]],[["f","if"],[["f","="],["w","target"],["w","current"]],["w","target"],[["f","if"],[["f",">"],["w","current"],["w","target"]],[["f","search"],["w","arr"],["w","target"],["w","start"],[["f","-"],["w","index"],["a",1]]],[["f","search"],["w","arr"],["w","target"],[["f","+"],["w","index"],["a",1]],["w","end"]]]]]]]]],[["f","search"],["w","arr"],["w","target"],["a",0],[["f","length"],["w","arr"]]]]]],[["f","let"],["w","array:zip"],[["f","lambda"],["w","A"],["w","B"],[["f","do"],[["f","let*"],["w","iterate"],[["f","lambda"],["w","a"],["w","b"],["w","output"],[["f","if"],[["f","and"],[["f","length"],["w","a"]],[["f","length"],["w","b"]]],[["f","iterate"],[["f","cdr"],["w","a"]],[["f","cdr"],["w","b"]],[["f","array:merge!"],["w","output"],[["f","array"],[["f","array"],[["f","car"],["w","a"]],[["f","car"],["w","b"]]]]]],["w","output"]]]],[["f","iterate"],["w","A"],["w","B"],[]]]]],[["f","let"],["w","math:cartesian-product"],[["f","lambda"],["w","a"],["w","b"],[["f","array:fold"],["w","a"],[["f","lambda"],["w","p"],["w","x"],[["f","array:merge!"],["w","p"],[["f","array:map"],["w","b"],[["f","lambda"],["w","y"],[["f","array"],["w","x"],["w","y"]]]]]],[]]]],[["f","let"],["w","array:equal?"],[["f","lambda"],["w","a"],["w","b"],[["f","or"],[["f","and"],[["f","number?"],["w","a"]],[["f","number?"],["w","b"]],[["f","="],["w","a"],["w","b"]]],[["f","and"],[["f","string?"],["w","a"]],[["f","string?"],["w","b"]],[["f","string:equal?"],["w","a"],["w","b"]]],[["f","and"],[["f","array?"],["w","a"]],[["f","="],[["f","length"],["w","a"]],[["f","length"],["w","b"]]],[["f","not"],[["f","array:some?"],[["f","math:sequence"],["w","a"]],[["f","lambda"],["w","i"],[["f","not"],[["f","array:equal?"],[["f","array:get"],["w","a"],["w","i"]],[["f","array:get"],["w","b"],["w","i"]]]]]]]]]]],[["f","let"],["w","array:join"],[["f","lambda"],["w","arr"],["w","delim"],[["f","array:fold"],[["f","array:zip"],["w","arr"],[["f","math:sequence"],["w","arr"]]],[["f","lambda"],["w","a"],["w","b"],[["f","if"],[["f",">"],[["f","car"],[["f","cdr"],["w","b"]]],["a",0]],[["f","string:merge"],["w","a"],["w","delim"],[["f","type"],[["f","car"],["w","b"]],["w","string"]]],[["f","type"],[["f","car"],["w","b"]],["w","string"]]]],["a",""]]]],[["f","let"],["w","array:flat-one"],[["f","lambda"],["w","arr"],[["f","array:fold"],["w","arr"],[["f","lambda"],["w","a"],["w","b"],[["f","array:merge!"],["w","a"],[["f","if"],[["f","array?"],["w","b"]],["w","b"],[["f","array"],["w","b"]]]]],[]]]],[["f","let"],["w","array:flat"],[["f","lambda"],["w","arr"],[["f","do"],[["f","let"],["w","flatten"],[["f","lambda"],["w","item"],[["f","if"],[["f","and"],[["f","array?"],["w","item"]],[["f","length"],["w","item"]]],[["f","array:fold"],["w","item"],[["f","lambda"],["w","a"],["w","b"],[["f","array:merge!"],["w","a"],[["f","flatten"],["w","b"]]]],[]],[["f","array"],["w","item"]]]]],[["f","flatten"],["w","arr"]]]]],[["f","let"],["w","array:sort"],[["f","lambda"],["w","arr"],["w","callback"],[["f","do"],[["f","if"],[["f","<="],[["f","length"],["w","arr"]],["a",1]],["w","arr"],[["f","do"],[["f","let"],["w","pivot"],[["f","car"],["w","arr"]]],[["f","let*"],["w","iterate"],[["f","lambda"],["w","i"],["w","bounds"],["w","a"],["w","b"],[["f","do"],[["f","let"],["w","current"],[["f","array:get"],["w","arr"],["w","i"]]],[["f","let"],["w","predicate"],[["f","callback"],["w","current"],["w","pivot"]]],[["f","let"],["w","left"],[["f","if"],[["f","="],["w","predicate"],["a",0]],[["f","array:merge"],["w","a"],[["f","array"],["w","current"]]],["w","a"]]],[["f","let"],["w","right"],[["f","if"],[["f","="],["w","predicate"],["a",1]],[["f","array:merge"],["w","b"],[["f","array"],["w","current"]]],["w","b"]]],[["f","if"],[["f","<"],["w","i"],["w","bounds"]],[["f","iterate"],[["f","+"],["w","i"],["a",1]],["w","bounds"],["w","left"],["w","right"]],[["f","array"],["w","left"],["w","right"]]]]]],[["f","let"],["w","sorted"],[["f","iterate"],["a",1],[["f","-"],[["f","length"],["w","arr"]],["a",1]],[],[]]],[["f","let"],["w","left"],[["f","car"],["w","sorted"]]],[["f","let"],["w","right"],[["f","car"],[["f","cdr"],["w","sorted"]]]],[["f","array:merge"],[["f","array:sort"],["w","left"],["w","callback"]],[["f","array"],["w","pivot"]],[["f","array:sort"],["w","right"],["w","callback"]]]]]]]],[["f","let"],["w","array:set"],[["f","lambda"],["w","arr"],["w","index"],["w","item"],[["f","array:set!"],[["f","type"],["w","arr"],["w","array"]],["w","index"],["w","item"]]]],[["f","let"],["w","array:adjacent-difference"],[["f","lambda"],["w","arr"],["w","callback"],[["f","do"],[["f","let"],["w","len"],[["f","length"],["w","arr"]]],[["f","unless"],[["f","="],["w","len"],["a",1]],[["f","do"],[["f","array"],[["f","car"],["w","arr"]]],[["f","let*"],["w","iterate"],[["f","lambda"],["w","i"],["w","result"],[["f","if"],[["f","<"],["w","i"],["w","len"]],[["f","do"],[["f","iterate"],[["f","+"],["w","i"],["a",1]],[["f","array:set!"],["w","result"],["w","i"],[["f","callback"],[["f","array:get"],["w","arr"],[["f","-"],["w","i"],["a",1]]],[["f","array:get"],["w","arr"],["w","i"]]]]]],["w","result"]]]],[["f","iterate"],["a",1],["w","arr"]]],["w","arr"]]]]],[["f","let"],["w","array:adjacent-find"],[["f","lambda"],["w","arr"],["w","callback"],[["f","do"],[["f","let"],["w","len"],[["f","length"],["w","arr"]]],[["f","otherwise"],[["f","="],["w","len"],["a",1]],[["f","do"],[["f","let*"],["w","iterate"],[["f","lambda"],["w","i"],[["f","if"],[["f","<"],["w","i"],["w","len"]],[["f","if"],[["f","callback"],[["f","let"],["w","prev"],[["f","array:get"],["w","arr"],[["f","-"],["w","i"],["a",1]]]],[["f","let"],["w","current"],[["f","array:get"],["w","arr"],["w","i"]]]],["w","prev"],[["f","iterate"],[["f","+"],["w","i"],["a",1]]]],[]]]],[["f","iterate"],["a",1]]]]]]],[["f","let"],["w","array:adjacent"],[["f","lambda"],["w","arr"],["w","directions"],["w","y"],["w","x"],["w","callback"],[["f","array:for"],["w","directions"],[["f","lambda"],["w","dir"],[["f","do"],[["f","let"],["w","dy"],[["f","+"],[["f","car"],["w","dir"]],["w","y"]]],[["f","let"],["w","dx"],[["f","+"],[["f","car"],[["f","cdr"],["w","dir"]]],["w","x"]]],[["f","when"],[["f","and"],[["f","array:in-bounds?"],["w","arr"],["w","dy"]],[["f","array:in-bounds?"],[["f","array:get"],["w","arr"],["w","dy"]],["w","dx"]]],[["f","callback"],[["f","array:get"],[["f","array:get"],["w","arr"],["w","dy"]],["w","dx"]],["w","dir"]]]]]]]],[["f","let"],["w","array:partition"],[["f","lambda"],["w","arr"],["w","n"],[["f","array:fold"],[["f","array:zip"],["w","arr"],[["f","math:sequence"],["w","arr"]]],[["f","lambda"],["w","a"],["w","b"],[["f","do"],[["f","let"],["w","x"],[["f","car"],["w","b"]]],[["f","let"],["w","i"],[["f","car"],[["f","cdr"],["w","b"]]]],[["f","if"],[["f","mod"],["w","i"],["w","n"]],[["f","array:set!"],[["f","let"],["w","last-a"],[["f","array:get"],["w","a"],["a",-1]]],[["f","length"],["w","last-a"]],["w","x"]],[["f","array:set!"],["w","a"],[["f","length"],["w","a"]],[["f","do"],[["f","let"],["w","mut-arr"],[]],[["f","array:set!"],["w","mut-arr"],[["f","length"],["w","mut-arr"]],["w","x"]]]]],["w","a"]]],[]]]],[["f","let"],["w","string:split"],[["f","lambda"],["w","str"],["w","delim"],[["f","do"],[["f","let"],["w","locals"],[]],[["f","let"],["w","delim-arr"],[["f","type"],["w","delim"],["w","array"]]],[["f","array:set!"],["w","locals"],[["f","length"],["w","locals"]],["w","delim-arr"]],[["f","array:set!"],["w","locals"],[["f","length"],["w","locals"]],[["f","type"],["w","str"],["w","array"]]],[["f","array:set!"],["w","locals"],[["f","length"],["w","locals"]],[["f","length"],["w","delim-arr"]]],[["f","array:set!"],["w","locals"],[["f","length"],["w","locals"]],["a",""]],[["f","let*"],["w","iterate"],[["f","lambda"],["w","result"],["w","i"],["w","bounds"],[["f","if"],[["f","<"],[["f","if"],[["f","array:every?"],[["f","array:zip"],[["f","array:get"],["w","locals"],["a",0]],[["f","math:sequence"],["w","locals"]]],[["f","lambda"],["w","item"],[["f","do"],[["f","let"],["w","y"],[["f","car"],["w","item"]]],[["f","let"],["w","j"],[["f","car"],[["f","cdr"],["w","item"]]]],[["f","or"],[["f","<="],[["f","length"],[["f","array:get"],["w","locals"],["a",1]]],[["f","+"],["w","i"],["w","j"]]],[["f","="],[["f","type"],[["f","array:get"],[["f","array:get"],["w","locals"],["a",1]],[["f","+"],["w","i"],["w","j"]]],["w","char-code"]],[["f","type"],["w","y"],["w","char-code"]]]]]]],[["f","do"],[["f","array:set!"],["w","result"],[["f","length"],["w","result"]],[["f","array:get"],["w","locals"],["a",3]]],[["f","array:set!"],["w","locals"],["a",3],["a",""]],[["f","+"],["w","i"],[["f","array:get"],["w","locals"],["a",2]],["a",-1]]],[["f","do"],[["f","array:set!"],["w","locals"],["a",3],[["f","string:merge"],[["f","array:get"],["w","locals"],["a",3]],[["f","array:get"],[["f","array:get"],["w","locals"],["a",1]],["w","i"]]]],["w","i"]]],["w","bounds"]],[["f","iterate"],["w","result"],[["f","+"],["w","i"],["a",1]],["w","bounds"]],["w","result"]]]],[["f","array:set!"],[["f","let"],["w","iteration-result"],[["f","iterate"],[],["a",0],[["f","-"],[["f","length"],[["f","array:get"],["w","locals"],["a",1]]],["a",1]]]],[["f","length"],["w","iteration-result"]],[["f","array:get"],["w","locals"],["a",3]]]]]],[["f","let"],["w","array:shallow-copy"],[["f","lambda"],["w","arr"],[["f","array:fold"],["w","arr"],[["f","lambda"],["w","a"],["w","b"],[["f","array:set!"],["w","a"],[["f","length"],["w","a"]],["w","b"]]],[]]]],[["f","let"],["w","array:deep-copy"],[["f","lambda"],["w","arr"],[["f","array:fold"],["w","arr"],[["f","lambda"],["w","a"],["w","b"],[["f","array:set!"],["w","a"],[["f","length"],["w","a"]],[["f","if"],[["f","array?"],["w","b"]],[["f","array:deep-copy"],["w","b"]],["w","b"]]]],[]]]],[["f","let"],["w","array:merge!"],[["f","lambda"],["w","a"],["w","b"],[["f","do"],[["f","array:for"],["w","b"],[["f","lambda"],["w","x"],[["f","array:set!"],["w","a"],[["f","length"],["w","a"]],["w","x"]]]],["w","a"]]]],[["f","let"],["w","array:swap-remove!"],[["f","lambda"],["w","arr"],["w","i"],[["f","do"],[["f","array:set!"],["w","arr"],["w","i"],[["f","array:get"],["w","arr"],[["f","-"],[["f","length"],["w","arr"]],["a",1]]]],[["f","array:set!"],["w","arr"],["a",-1]]]]],[["f","let"],["w","array:index-of"],[["f","safety"],["w","lambda"],["w","arr"],["w","item"],[["f","do"],[["f","let*"],["w","iterate"],[["f","lambda"],["w","arr"],["w","i"],[["f","if"],[["f","length"],["w","arr"]],[["f","if"],[["f","="],[["f","car"],["w","arr"]],["w","item"]],["w","i"],[["f","iterate"],[["f","cdr"],["w","arr"]],[["f","+"],["w","i"],["a",1]]]],["a",-1]]]],[["f","iterate"],["w","arr"],["a",0]]]]],[["f","let"],["w","string:index-of-char"],[["f","lambda"],["w","str"],["w","character"],[["f","do"],[["f","let*"],["w","iterate"],[["f","lambda"],["w","arr"],["w","i"],[["f","if"],[["f","length"],["w","arr"]],[["f","if"],[["f","string:equal?"],[["f","car"],["w","arr"]],["w","character"]],["w","i"],[["f","iterate"],[["f","cdr"],["w","arr"]],[["f","+"],["w","i"],["a",1]]]],["a",-1]]]],[["f","iterate"],[["f","type"],["w","str"],["w","array"]],["a",0]]]]],[["f","let"],["w","string:match"],[["f","lambda"],["w","str"],["w","word"],[["f","do"],[["f","let"],["w","string-arr"],[["f","type"],["w","str"],["w","array"]]],[["f","let*"],["w","iterate"],[["f","lambda"],["w","arr"],["w","i"],[["f","if"],[["f","length"],["w","arr"]],[["f","if"],[["f","string:equal?"],[["f","pi"],["w","string-arr"],[["f","array:slice"],["w","i"],[["f","+"],["w","i"],[["f","length"],["w","word"]]]],[["f","array:join"],["a",""]]],["w","word"]],["w","i"],[["f","iterate"],[["f","cdr"],["w","arr"]],[["f","+"],["w","i"],["a",1]]]],["a",-1]]]],[["f","iterate"],["w","toArr"],["a",0]]]]],[["f","let"],["w","array:find-index"],[["f","safety"],["w","lambda"],["w","arr"],["w","callback"],[["f","do"],[["f","let*"],["w","iterate"],[["f","lambda"],["w","arr"],["w","i"],[["f","if"],[["f","length"],["w","arr"]],[["f","if"],[["f","callback"],[["f","car"],["w","arr"]]],["w","i"],[["f","iterate"],[["f","cdr"],["w","arr"]],[["f","+"],["w","i"],["a",1]]]],["a",-1]]]],[["f","iterate"],["w","arr"],["a",0]]]]],[["f","let"],["w","array:remove"],[["f","lambda"],["w","arr"],["w","i"],[["f","array:fold"],["w","arr"],[["f","lambda"],["w","a"],["w","x"],[["f","do"],[["f","unless"],[["f","="],["w","x"],["w","i"]],[["f","array:merge!"],["w","a"],[["f","array"],["w","x"]]],["w","a"]]]],[]]]],[["f","let"],["w","array:pad-right"],[["f","lambda"],["w","a"],["w","b"],[["f","if"],[["f",">"],[["f","length"],["w","a"]],[["f","length"],["w","b"]]],[["f","array:merge"],["w","b"],[["f","array"],[["f","-"],[["f","length"],["w","a"]],[["f","length"],["w","b"]]],["w","length"]]],[["f","array:merge"],["w","a"],[["f","array"],[["f","-"],[["f","length"],["w","b"]],[["f","length"],["w","a"]]],["w","length"]]]]]],[["f","let"],["w","array:pad-left"],[["f","lambda"],["w","a"],["w","b"],[["f","if"],[["f",">"],[["f","length"],["w","a"]],[["f","length"],["w","b"]]],[["f","array:merge"],[["f","array"],[["f","-"],[["f","length"],["w","a"]],[["f","length"],["w","b"]]],["w","length"]],["w","b"]],[["f","array:merge"],[["f","array"],[["f","-"],[["f","length"],["w","b"]],[["f","length"],["w","a"]]],["w","length"]],["w","a"]]]]],[["f","let"],["w","array:pad-right!"],[["f","lambda"],["w","a"],["w","b"],[["f","if"],[["f",">"],[["f","length"],["w","a"]],[["f","length"],["w","b"]]],[["f","array:merge!"],["w","b"],[["f","array"],[["f","-"],[["f","length"],["w","a"]],[["f","length"],["w","b"]]],["w","length"]]],[["f","array:merge!"],["w","a"],[["f","array"],[["f","-"],[["f","length"],["w","b"]],[["f","length"],["w","a"]]],["w","length"]]]]]],[["f","let"],["w","array:pad-left!"],[["f","lambda"],["w","a"],["w","b"],[["f","if"],[["f",">"],[["f","length"],["w","a"]],[["f","length"],["w","b"]]],[["f","array:merge!"],[["f","array"],[["f","-"],[["f","length"],["w","a"]],[["f","length"],["w","b"]]],["w","length"]],["w","b"]],[["f","array:merge!"],[["f","array"],[["f","-"],[["f","length"],["w","b"]],[["f","length"],["w","a"]]],["w","length"]],["w","a"]]]]],[["f","let"],["w","string:greater?"],[["f","lambda"],["w","L"],["w","R"],[["f","otherwise"],[["f","string:equal?"],["w","L"],["w","R"]],[["f","do"],[["f","let"],["w","A"],[["f","cast:string->char-codes"],[["f","type"],["w","L"],["w","string"]]]],[["f","let"],["w","B"],[["f","cast:string->char-codes"],[["f","type"],["w","R"],["w","string"]]]],[["f","let"],["w","a"],[["f","if"],[["f","<"],[["f","length"],["w","A"]],[["f","length"],["w","B"]]],[["f","array:merge!"],["w","A"],[["f","array"],[["f","-"],[["f","length"],["w","B"]],[["f","length"],["w","A"]]],["w","length"]]],["w","A"]]],[["f","let"],["w","b"],[["f","if"],[["f",">"],[["f","length"],["w","A"]],[["f","length"],["w","B"]]],[["f","array:merge!"],["w","B"],[["f","array"],[["f","-"],[["f","length"],["w","A"]],[["f","length"],["w","B"]]],["w","length"]]],["w","B"]]],[["f","pi"],["w","a"],[["f","array:zip"],["w","b"]],[["f","array:fold"],[["f","lambda"],["w","acc"],["w","pair"],[["f","if"],[["f",">"],[["f","car"],["w","pair"]],[["f","car"],[["f","cdr"],["w","pair"]]]],["a",0],["w","acc"]]],["a",1]]]]]]],[["f","let"],["w","string:lesser?"],[["f","lambda"],["w","L"],["w","R"],[["f","otherwise"],[["f","string:equal?"],["w","L"],["w","R"]],[["f","do"],[["f","let"],["w","A"],[["f","cast:string->char-codes"],[["f","type"],["w","L"],["w","string"]]]],[["f","let"],["w","B"],[["f","cast:string->char-codes"],[["f","type"],["w","R"],["w","string"]]]],[["f","let"],["w","a"],[["f","if"],[["f","<"],[["f","length"],["w","A"]],[["f","length"],["w","B"]]],[["f","array:merge!"],["w","A"],[["f","array"],[["f","-"],[["f","length"],["w","B"]],[["f","length"],["w","A"]]],["w","length"]]],["w","A"]]],[["f","let"],["w","b"],[["f","if"],[["f",">"],[["f","length"],["w","A"]],[["f","length"],["w","B"]]],[["f","array:merge!"],["w","B"],[["f","array"],[["f","-"],[["f","length"],["w","A"]],[["f","length"],["w","B"]]],["w","length"]]],["w","B"]]],[["f","pi"],["w","a"],[["f","array:zip"],["w","b"]],[["f","array:fold"],[["f","lambda"],["w","acc"],["w","pair"],[["f","if"],[["f","<"],[["f","car"],["w","pair"]],[["f","car"],[["f","cdr"],["w","pair"]]]],["a",0],["w","acc"]]],["a",1]]]]]]],[["f","let"],["w","string:equal?"],[["f","lambda"],["w","L"],["w","R"],[["f","when"],[["f","="],[["f","length"],["w","L"]],[["f","length"],["w","R"]]],[["f","do"],[["f","let"],["w","a"],[["f","cast:string->char-codes"],["w","R"]]],[["f","let"],["w","b"],[["f","cast:string->char-codes"],["w","L"]]],[["f","pi"],["w","a"],[["f","array:zip"],["w","b"]],[["f","array:every?"],[["f","lambda"],["w","x"],[["f","="],[["f","car"],["w","x"]],[["f","car"],[["f","cdr"],["w","x"]]]]]]]]]]],[["f","let"],["w","new:set"],[["f","lambda"],["w","items"],[["f","set:add!"],[["f","array"],[],[],[],[]],["w","items"]]]],[["f","let"],["w","new:array"],[["f","safety"],["w","lambda"],["w","items"],[["f","type"],["w","items"],["w","array"]]]],[["f","let"],["w","new:list"],[["f","safety"],["w","lambda"],["w","value"],[["f","array"],[],["w","value"],[]]]],[["f","let"],["w","new:binary-tree"],[["f","safety"],["w","lambda"],["w","value"],[["f","do"],[["f","let"],["w","arr"],[]],[["f","array:set!"],["w","arr"],["a",0],["w","value"]],[["f","array:set!"],["w","arr"],["a",1],[]],[["f","array:set!"],["w","arr"],["a",2],[]],["w","arr"]]]],[["f","let"],["w","binary-tree:left"],[["f","safety"],["w","lambda"],["w","node"],[["f","array:get"],["w","node"],["a",1]]]],[["f","let"],["w","binary-tree:right"],[["f","safety"],["w","lambda"],["w","node"],[["f","array:get"],["w","node"],["a",2]]]],[["f","let"],["w","binary-tree:left!"],[["f","safety"],["w","lambda"],["w","tree"],["w","node"],[["f","array:set!"],["w","tree"],["a",1],["w","node"]]]],[["f","let"],["w","binary-tree:right!"],[["f","safety"],["w","lambda"],["w","tree"],["w","node"],[["f","array:set!"],["w","tree"],["a",2],["w","node"]]]],[["f","let"],["w","binary-tree:value"],[["f","safety"],["w","lambda"],["w","node"],[["f","car"],["w","node"]]]],[["f","let"],["w","set:index"],[["f","lambda"],["w","table"],["w","key"],[["f","do"],[["f","let"],["w","prime-num"],["a",31]],[["f","let"],["w","key-arr"],[["f","type"],[["f","type"],["w","key"],["w","string"]],["w","array"]]],[["f","let"],["w","total"],[["f","array"],["a",0]]],[["f","let*"],["w","find-hash-index"],[["f","lambda"],["w","i"],["w","bounds"],[["f","do"],[["f","let"],["w","letter"],[["f","array:get"],["w","key-arr"],["w","i"]]],[["f","let"],["w","value"],[["f","-"],[["f","type"],["w","letter"],["w","char-code"]],["a",96]]],[["f","array:set!"],["w","total"],["a",0],[["f","math:euclidean-mod"],[["f","+"],[["f","*"],[["f","car"],["w","total"]],["w","prime-num"]],["w","value"]],[["f","length"],["w","table"]]]],[["f","if"],[["f","<"],["w","i"],["w","bounds"]],[["f","find-hash-index"],[["f","+"],["w","i"],["a",1]],["w","bounds"]],[["f","car"],["w","total"]]]]]],[["f","find-hash-index"],["a",0],[["f","if"],[["f","<"],[["f","-"],[["f","length"],["w","key-arr"]],["a",1]],["a",100]],[["f","-"],[["f","length"],["w","key-arr"]],["a",1]],["a",100]]]]]],[["f","let"],["w","set:add!"],[["f","lambda"],["w","table"],["w","key"],[["f","do"],[["f","let"],["w","idx"],[["f","set:index"],["w","table"],["w","key"]]],[["f","otherwise"],[["f","array:in-bounds?"],["w","table"],["w","idx"]],[["f","array:set!"],["w","table"],["w","idx"],[["f","array"]]]],[["f","let"],["w","current"],[["f","array:get"],["w","table"],["w","idx"]]],[["f","let"],["w","len"],[["f","length"],["w","current"]]],[["f","let"],["w","index"],[["f","if"],["w","len"],[["f","array:find-index"],["w","current"],[["f","lambda"],["w","x"],[["f","string:equal?"],[["f","type"],["w","x"],["w","string"]],[["f","type"],["w","key"],["w","string"]]]]],["a",-1]]],[["f","let"],["w","entry"],["w","key"]],[["f","if"],[["f","="],["w","index"],["a",-1]],[["f","array:set!"],["w","current"],[["f","length"],["w","current"]],["w","entry"]],[["f","array:set!"],["w","current"],["w","index"],["w","entry"]]],["w","table"]]]],[["f","let"],["w","set:remove!"],[["f","lambda"],["w","table"],["w","key"],[["f","do"],[["f","let"],["w","idx"],[["f","set:index"],["w","table"],["w","key"]]],[["f","otherwise"],[["f","array:in-bounds?"],["w","table"],["w","idx"]],[["f","array:set!"],["w","table"],["w","idx"],[["f","Array"]]]],[["f","let"],["w","current"],[["f","array:get"],["w","table"],["w","idx"]]],[["f","let"],["w","len"],[["f","length"],["w","current"]]],[["f","let"],["w","index"],[["f","if"],["w","len"],[["f","array:find-index"],["w","current"],[["f","lambda"],["w","x"],[["f","string:equal?"],[["f","type"],["w","x"],["w","string"]],[["f","type"],["w","key"],["w","string"]]]]],["a",-1]]],[["f","let"],["w","entry"],["w","key"]],[["f","otherwise"],[["f","="],["w","index"],["a",-1]],[["f","and"],[["f","array:set!"],["w","current"],["w","index"],[["f","array:get"],["w","current"],["a",-1]]],[["f","array:set!"],["w","current"],["a",-1]]]],["w","table"]]]],[["f","let"],["w","set:has?"],[["f","lambda"],["w","table"],["w","key"],[["f","and"],[["f","array:in-bounds?"],["w","table"],[["f","let"],["w","idx"],[["f","set:index"],["w","table"],["w","key"]]]],[["f","and"],[["f","length"],[["f","let"],["w","current"],[["f","array:get"],["w","table"],["w","idx"]]]],[["f",">="],[["f","array:find-index"],["w","current"],[["f","lambda"],["w","x"],[["f","string:equal?"],[["f","type"],["w","x"],["w","string"]],[["f","type"],["w","key"],["w","string"]]]]],["a",0]]]]]],[["f","let"],["w","set:intersection"],[["f","lambda"],["w","a"],["w","b"],[["f","pi"],["w","b"],[["f","cast:table->array"]],[["f","array:fold"],[["f","lambda"],["w","out"],["w","element"],[["f","do"],[["f","when"],[["f","set:has?"],["w","a"],["w","element"]],[["f","set:add!"],["w","out"],["w","element"]]],["w","out"]]],[["f","array"],[],[],[],[],[]]]]]],[["f","let"],["w","set:difference"],[["f","lambda"],["w","a"],["w","b"],[["f","pi"],["w","a"],[["f","cast:table->array"]],[["f","array:fold"],[["f","lambda"],["w","out"],["w","element"],[["f","do"],[["f","when"],[["f","not"],[["f","set:has?"],["w","b"],["w","element"]]],[["f","set:add!"],["w","out"],["w","element"]]],["w","out"]]],[["f","array"],[],[],[],[],[]]]]]],[["f","let"],["w","set:xor"],[["f","lambda"],["w","a"],["w","b"],[["f","do"],[["f","let"],["w","out"],[["f","array"],[],[],[],[],[]]],[["f","pi"],["w","a"],[["f","cast:table->array"]],[["f","array:for"],[["f","lambda"],["w","element"],[["f","when"],[["f","not"],[["f","set:has?"],["w","b"],["w","element"]]],[["f","set:add!"],["w","out"],["w","element"]]]]]],[["f","pi"],["w","b"],[["f","cast:table->array"]],[["f","array:for"],[["f","lambda"],["w","element"],[["f","when"],[["f","not"],[["f","set:has?"],["w","a"],["w","element"]]],[["f","set:add!"],["w","out"],["w","element"]]]]]],["w","out"]]]],[["f","let"],["w","set:union"],[["f","lambda"],["w","a"],["w","b"],[["f","do"],[["f","let"],["w","out"],[["f","array"],[],[],[],[],[]]],[["f","pi"],["w","a"],[["f","cast:table->array"]],[["f","array:for"],[["f","lambda"],["w","element"],[["f","set:add!"],["w","out"],["w","element"]]]]],[["f","pi"],["w","b"],[["f","cast:table->array"]],[["f","array:for"],[["f","lambda"],["w","element"],[["f","set:add!"],["w","out"],["w","element"]]]]],["w","out"]]]],[["f","let"],["w","cast:table->array"],[["f","lambda"],["w","set"],[["f","array:select"],[["f","array:flat"],["w","set"]],["w","atom?"]]]],[["f","let"],["w","set:empty!"],[["f","lambda"],["w","table"],[["f","array:map"],["w","table"],["w","empty!"]]]],[["f","let"],["w","map:empty!"],[["f","lambda"],["w","table"],[["f","array:map"],["w","table"],["w","empty!"]]]],[["f","let"],["w","map:set!"],[["f","lambda"],["w","table"],["w","key"],["w","value"],[["f","do"],[["f","let"],["w","idx"],[["f","set:index"],["w","table"],["w","key"]]],[["f","otherwise"],[["f","array:in-bounds?"],["w","table"],["w","idx"]],[["f","array:set!"],["w","table"],["w","idx"],[]]],[["f","let"],["w","current"],[["f","array:get"],["w","table"],["w","idx"]]],[["f","let"],["w","len"],[["f","length"],["w","current"]]],[["f","let"],["w","index"],[["f","if"],["w","len"],[["f","array:find-index"],["w","current"],[["f","lambda"],["w","x"],[["f","string:equal?"],[["f","type"],[["f","car"],["w","x"]],["w","string"]],[["f","type"],["w","key"],["w","string"]]]]],["a",-1]]],[["f","let"],["w","entry"],[["f","array"],["w","key"],["w","value"]]],[["f","if"],[["f","="],["w","index"],["a",-1]],[["f","array:set!"],["w","current"],[["f","length"],["w","current"]],["w","entry"]],[["f","array:set!"],["w","current"],["w","index"],["w","entry"]]],["w","table"]]]],[["f","let"],["w","map:remove!"],[["f","lambda"],["w","table"],["w","key"],[["f","do"],[["f","let"],["w","idx"],[["f","set:index"],["w","table"],["w","key"]]],[["f","otherwise"],[["f","array:in-bounds?"],["w","table"],["w","idx"]],[["f","array:set!"],["w","table"],["w","idx"],[]]],[["f","let"],["w","current"],[["f","array:get"],["w","table"],["w","idx"]]],[["f","let"],["w","len"],[["f","length"],["w","current"]]],[["f","let"],["w","index"],[["f","if"],["w","len"],[["f","array:find-index"],["w","current"],[["f","lambda"],["w","x"],[["f","string:equal?"],[["f","type"],[["f","car"],["w","x"]],["w","string"]],[["f","type"],["w","key"],["w","string"]]]]],["a",-1]]],[["f","otherwise"],[["f","="],["w","index"],["a",-1]],[["f","and"],[["f","array:set!"],["w","current"],["w","index"],[["f","array:get"],["w","current"],["a",-1]]],[["f","array:set!"],["w","current"],["a",-1]]]],["w","table"]]]],[["f","let"],["w","map:get"],[["f","lambda"],["w","table"],["w","key"],[["f","do"],[["f","let"],["w","idx"],[["f","set:index"],["w","table"],["w","key"]]],[["f","when"],[["f","array:in-bounds?"],["w","table"],["w","idx"]],[["f","do"],[["f","let"],["w","current"],[["f","array:get"],["w","table"],["w","idx"]]],[["f","let"],["w","found"],[["f","array:find"],["w","current"],[["f","lambda"],["w","x"],[["f","string:equal?"],[["f","type"],["w","key"],["w","string"]],[["f","type"],[["f","array:get"],["w","x"],["a",0]],["w","string"]]]]]],[["f","when"],[["f","length"],["w","found"]],[["f","array:get"],["w","found"],["a",1]]]]]]]],[["f","let"],["w","cast:map->string"],[["f","lambda"],["w","table"],[["f","pi"],["w","table"],[["f","array:select"],["w","length"]],[["f","array:map"],[["f","lambda"],["w","x"],[["f","array:join"],[["f","array:map"],["w","x"],[["f","lambda"],["w","y"],[["f","array:join"],["w","y"],["a"," -> "]]]],["a"," "]]]],[["f","array:join"],["a","\n"]]]]],[["f","let"],["w","map:has?"],[["f","lambda"],["w","table"],["w","key"],[["f","and"],[["f","array:in-bounds?"],["w","table"],[["f","let"],["w","idx"],[["f","set:index"],["w","table"],["w","key"]]]],[["f","and"],[["f","length"],[["f","let"],["w","current"],[["f","array:get"],["w","table"],["w","idx"]]]],[["f",">="],[["f","array:find-index"],[["f","car"],["w","current"]],[["f","lambda"],["w","x"],[["f","string:equal?"],[["f","type"],["w","x"],["w","string"]],[["f","type"],["w","key"],["w","string"]]]]],["a",0]]]]]],[["f","let"],["w","list:prev!"],[["f","safety"],["w","lambda"],["w","list"],["w","node"],[["f","array:set!"],["w","list"],["a",0],[["f","array:set!"],["w","node"],["a",2],["w","list"]]]]],[["f","let"],["w","list:next!"],[["f","safety"],["w","lambda"],["w","list"],["w","node"],[["f","array:set!"],["w","list"],["a",2],[["f","array:set!"],["w","node"],["a",0],["w","list"]]]]],[["f","let"],["w","list:prev"],[["f","safety"],["w","lambda"],["w","list"],[["f","array:get"],["w","list"],["a",0]]]],[["f","let"],["w","list:next"],[["f","safety"],["w","lambda"],["w","list"],[["f","array:get"],["w","list"],["a",2]]]],[["f","let"],["w","list:value"],[["f","lambda"],["w","node"],[["f","array:get"],["w","node"],["a",1]]]],[["f","let"],["w","array:rotate-right"],[["f","lambda"],["w","arr"],["w","n"],[["f","pi"],["w","arr"],[["f","array:zip"],[["f","math:sequence"],["w","arr"]]],[["f","array:fold"],[["f","lambda"],["w","a"],["w","b"],[["f","array:set!"],["w","a"],[["f","mod"],[["f","+"],[["f","car"],[["f","cdr"],["w","b"]]],["w","n"]],[["f","length"],["w","arr"]]],[["f","car"],["w","b"]]]],[["f","array"],[["f","length"],["w","arr"]],["w","length"]]]]]],[["f","let"],["w","array:rotate-left"],[["f","lambda"],["w","arr"],["w","n"],[["f","pi"],["w","arr"],[["f","array:zip"],[["f","math:sequence"],["w","arr"]]],[["f","array:fold"],[["f","lambda"],["w","a"],["w","b"],[["f","array:set!"],["w","a"],[["f","mod"],[["f","+"],[["f","car"],[["f","cdr"],["w","b"]]],[["f","-"],[["f","length"],["w","arr"]],["w","n"]]],[["f","length"],["w","arr"]]],[["f","car"],["w","b"]]]],[["f","array"],[["f","length"],["w","arr"]],["w","length"]]]]]],[["f","let"],["w","var:def"],[["f","safety"],["w","lambda"],["w","val"],[["f","array"],["w","val"]]]],[["f","let"],["w","var:get"],[["f","safety"],["w","lambda"],["w","variable"],[["f","car"],["w","variable"]]]],[["f","let"],["w","var:set!"],[["f","safety"],["w","lambda"],["w","variable"],["w","value"],[["f","array:set!"],["w","variable"],["a",0],["w","value"]]]],[["f","let"],["w","var:del!"],[["f","safety"],["w","lambda"],["w","variable"],[["f","array:set!"],["w","variable"],["a",-1]]]],[["f","let"],["w","array:first"],[["f","safety"],["w","lambda"],["w","arr"],[["f","array:get"],["w","arr"],["a",0]]]],[["f","let"],["w","array:last"],[["f","safety"],["w","lambda"],["w","arr"],[["f","array:get"],["w","arr"],["a",-1]]]],[["f","let"],["w","string:trim-left"],[["f","lambda"],["w","str"],[["f","do"],[["f","let"],["w","tr"],[["f","array"],["a",1]]],[["f","pi"],["w","str"],[["f","type"],["w","array"]],[["f","array:fold"],[["f","lambda"],["w","a"],["w","b"],[["f","if"],[["f","and"],[["f","car"],["w","tr"]],[["f","string:equal?"],["w","b"],["a"," "]]],["w","a"],[["f","do"],[["f","when"],[["f","car"],["w","tr"]],[["f","array:set!"],["w","tr"],["a",0],["a",0]]],[["f","string:merge"],["w","a"],["w","b"]]]]],["a",""]]]]]],[["f","let"],["w","string:trim-right"],[["f","lambda"],["w","str"],[["f","do"],[["f","let"],["w","tr"],[["f","array"],["a",1]]],[["f","pi"],["w","str"],[["f","type"],["w","array"]],[["f","array:reverse"]],[["f","array:fold"],[["f","lambda"],["w","a"],["w","b"],[["f","if"],[["f","and"],[["f","car"],["w","tr"]],[["f","string:equal?"],["w","b"],["a"," "]]],["w","a"],[["f","do"],[["f","when"],[["f","car"],["w","tr"]],[["f","array:set!"],["w","tr"],["a",0],["a",0]]],[["f","string:merge"],["w","b"],["w","a"]]]]],["a",""]]]]]],[["f","let"],["w","string:trim"],[["f","lambda"],["w","str"],[["f","pi"],["w","str"],[["f","string:trim-left"]],[["f","string:trim-right"]]]]],[["f","let"],["w","array:enumerate"],[["f","lambda"],["w","arr"],[["f","array:zip"],[["f","math:sequence"],["w","arr"]],["w","arr"]]]],[["f","let"],["w","string:lines"],[["f","lambda"],["w","str"],[["f","pi"],["w","str"],[["f","type"],["w","array"]],[["f","array:fold"],[["f","lambda"],["w","a"],["w","b"],[["f","do"],[["f","let"],["w","prev"],[["f","array:get"],["w","a"],["a",-1]]],[["f","if"],[["f","string:equal?"],["w","b"],["a","\n"]],[["f","array:set!"],["w","a"],[["f","length"],["w","a"]],[]],[["f","array:set!"],["w","prev"],[["f","length"],["w","prev"]],["w","b"]]],["w","a"]]],[["f","array"],[]]],[["f","array:map"],[["f","lambda"],["w","x"],[["f","array:join"],["w","x"],["a",""]]]]]]],[["f","let"],["w","string:words"],[["f","lambda"],["w","str"],[["f","pi"],["w","str"],[["f","type"],["w","array"]],[["f","array:fold"],[["f","lambda"],["w","a"],["w","b"],[["f","do"],[["f","let"],["w","prev"],[["f","array:get"],["w","a"],["a",-1]]],[["f","if"],[["f","string:equal?"],["w","b"],["a"," "]],[["f","array:set!"],["w","a"],[["f","length"],["w","a"]],[]],[["f","array:set!"],["w","prev"],[["f","length"],["w","prev"]],["w","b"]]],["w","a"]]],[["f","array"],[]]],[["f","array:map"],[["f","lambda"],["w","x"],[["f","array:join"],["w","x"],["a",""]]]]]]],[["f","let"],["w","string:separator"],[["f","lambda"],["w","str"],["w","separator"],[["f","pi"],["w","str"],[["f","type"],["w","array"]],[["f","array:fold"],[["f","lambda"],["w","a"],["w","b"],[["f","do"],[["f","let"],["w","prev"],[["f","array:get"],["w","a"],["a",-1]]],[["f","if"],[["f","string:equal?"],["w","b"],["w","separator"]],[["f","array:set!"],["w","a"],[["f","length"],["w","a"]],[]],[["f","array:set!"],["w","prev"],[["f","length"],["w","prev"]],["w","b"]]],["w","a"]]],[["f","array"],[]]],[["f","array:map"],[["f","lambda"],["w","x"],[["f","array:join"],["w","x"],["a",""]]]]]]],[["f","let"],["w","new:brray"],[["f","lambda"],[["f","array"],[["f","array"],[]],[]]]],[["f","let"],["w","brray:offset-left"],[["f","lambda"],["w","q"],[["f","*"],[["f","-"],[["f","length"],[["f","array:get"],["w","q"],["a",0]]],["a",1]],["a",-1]]]],[["f","let"],["w","brray:offset-right"],[["f","lambda"],["w","q"],[["f","length"],[["f","array:get"],["w","q"],["a",1]]]]],[["f","let"],["w","brray:length"],[["f","lambda"],["w","q"],[["f","+"],[["f","length"],[["f","array:get"],["w","q"],["a",0]]],[["f","length"],[["f","array:get"],["w","q"],["a",1]]],["a",-1]]]],[["f","let"],["w","brray:empty?"],[["f","lambda"],["w","q"],[["f","not"],[["f","brray:length"],["w","q"]]]]],[["f","let"],["w","brray:empty!"],[["f","lambda"],["w","q"],[["f","do"],[["f","array:set!"],["w","q"],["a",0],[["f","array"],[]]],[["f","array:set!"],["w","q"],["a",1],[]],["w","q"]]]],[["f","let"],["w","brray:get"],[["f","lambda"],["w","q"],["w","offset"],[["f","do"],[["f","let"],["w","offset-index"],[["f","+"],["w","offset"],[["f","brray:offset-left"],["w","q"]]]],[["f","let"],["w","index"],[["f","if"],[["f","<"],["w","offset-index"],["a",0]],[["f","*"],["w","offset-index"],["a",-1]],["w","offset-index"]]],[["f","if"],[["f",">="],["w","offset-index"],["a",0]],[["f","array:get"],[["f","array:get"],["w","q"],["a",1]],["w","index"]],[["f","array:get"],[["f","array:get"],["w","q"],["a",0]],["w","index"]]]]]],[["f","let"],["w","brray:set!"],[["f","lambda"],["w","q"],["w","index"],["w","value"],[["f","do"],[["f","let"],["w","offset"],[["f","+"],["w","offset"],[["f","brray:offset-left"],["w","q"]]]],[["f","if"],[["f",">="],["w","offset"],["a",0]],[["f","array:set!"],[["f","array:get"],["w","q"],["a",1]],["w","offset"],["w","value"]],[["f","array:set!"],[["f","array:get"],["w","q"],["a",0]],[["f","*"],["w","offset"],["a",-1]],["w","value"]]],["w","q"]]]],[["f","let"],["w","brray:add-to-left!"],[["f","lambda"],["w","q"],["w","item"],[["f","array:set!"],[["f","let"],["w","c"],[["f","array:get"],["w","q"],["a",0]]],[["f","length"],["w","c"]],["w","item"]]]],[["f","let"],["w","brray:add-to-right!"],[["f","lambda"],["w","q"],["w","item"],[["f","array:set!"],[["f","let"],["w","c"],[["f","array:get"],["w","q"],["a",1]]],[["f","length"],["w","c"]],["w","item"]]]],[["f","let"],["w","brray:remove-from-left!"],[["f","lambda"],["w","q"],[["f","do"],[["f","let"],["w","len"],[["f","brray:length"],["w","q"]]],[["f","when"],["w","len"],[["f","cond"],[["f","="],["w","len"],["a",1]],[["f","brray:empty!"],["w","q"]],[["f",">"],[["f","length"],[["f","array:get"],["w","q"],["a",0]]],["a",0]],[["f","array:set!"],[["f","array:get"],["w","q"],["a",0]],["a",-1]]]]]]],[["f","let"],["w","brray:remove-from-right!"],[["f","lambda"],["w","q"],[["f","do"],[["f","let"],["w","len"],[["f","brray:length"],["w","q"]]],[["f","when"],["w","len"],[["f","cond"],[["f","="],["w","len"],["a",1]],[["f","brray:empty!"],["w","q"]],[["f",">"],[["f","length"],[["f","array:get"],["w","q"],["a",1]]],["a",0]],[["f","array:set!"],[["f","array:get"],["w","q"],["a",1]],["a",-1]]]]]]],[["f","let"],["w","brray:iter"],[["f","lambda"],["w","q"],["w","callback"],[["f","do"],[["f","let*"],["w","iter"],[["f","lambda"],["w","index"],["w","bounds"],[["f","do"],[["f","callback"],[["f","brray:get"],["w","q"],["w","index"]]],[["f","when"],[["f","<"],["w","index"],["w","bounds"]],[["f","iter"],[["f","+"],["w","index"],["a",1]],["w","bounds"]]]]]],[["f","iter"],["a",0],[["f","brray:length"],["w","q"]]]]]],[["f","let"],["w","brray:map"],[["f","lambda"],["w","q"],["w","callback"],[["f","do"],[["f","let"],["w","result"],[["f","new:brray"]]],[["f","let"],["w","len"],[["f","brray:length"],["w","q"]]],[["f","let"],["w","half"],[["f","math:floor"],[["f","*"],["w","len"],["a",0.5]]]],[["f","let*"],["w","left"],[["f","lambda"],["w","index"],[["f","do"],[["f","brray:add-to-left!"],["w","result"],[["f","callback"],[["f","brray:get"],["w","q"],["w","index"]]]],[["f","when"],[["f",">"],["w","index"],["a",0]],[["f","left"],[["f","-"],["w","index"],["a",1]]]]]]],[["f","left"],[["f","-"],["w","half"],["a",1]]],[["f","let*"],["w","rigth"],[["f","lambda"],["w","index"],["w","bounds"],[["f","do"],[["f","brray:add-to-right!"],["w","result"],[["f","callback"],[["f","brray:get"],["w","q"],["w","index"]]]],[["f","when"],[["f","<"],["w","index"],["w","bounds"]],[["f","rigth"],[["f","+"],["w","index"],["a",1]],["w","bounds"]]]]]],[["f","rigth"],["w","half"],[["f","-"],["w","len"],["a",1]]],["w","result"]]]],[["f","let"],["w","cast:brray->array"],[["f","lambda"],["w","q"],[["f","do"],[["f","let"],["w","out"],[]],[["f","let*"],["w","iter"],[["f","lambda"],["w","index"],["w","bounds"],[["f","do"],[["f","array:set!"],["w","out"],[["f","length"],["w","out"]],[["f","brray:get"],["w","q"],["w","index"]]],[["f","when"],[["f","<"],["w","index"],["w","bounds"]],[["f","iter"],[["f","+"],["w","index"],["a",1]],["w","bounds"]]]]]],[["f","iter"],["a",0],[["f","-"],[["f","brray:length"],["w","q"]],["a",1]]],["w","out"]]]],[["f","let"],["w","brray:balance?"],[["f","lambda"],["w","q"],[["f","="],[["f","+"],[["f","brray:offset-right"],["w","q"]],[["f","brray:offset-left"],["w","q"]]],["a",0]]]],[["f","let"],["w","brray:balance!"],[["f","lambda"],["w","q"],[["f","if"],[["f","brray:balance?"],["w","q"]],["w","q"],[["f","do"],[["f","let"],["w","initial"],[["f","cast:brray->array"],["w","q"]]],[["f","brray:empty!"],["w","q"]],[["f","let"],["w","half"],[["f","math:floor"],[["f","*"],[["f","length"],["w","initial"]],["a",0.5]]]],[["f","let*"],["w","left"],[["f","lambda"],["w","index"],[["f","do"],[["f","brray:add-to-left!"],["w","q"],[["f","array:get"],["w","initial"],["w","index"]]],[["f","when"],[["f",">"],["w","index"],["a",0]],[["f","left"],[["f","-"],["w","index"],["a",1]]]]]]],[["f","left"],[["f","-"],["w","half"],["a",1]]],[["f","let*"],["w","rigth"],[["f","lambda"],["w","index"],["w","bounds"],[["f","do"],[["f","brray:add-to-right!"],["w","q"],[["f","array:get"],["w","initial"],["w","index"]]],[["f","when"],[["f","<"],["w","index"],["w","bounds"]],[["f","rigth"],[["f","+"],["w","index"],["a",1]],["w","bounds"]]]]]],[["f","rigth"],["w","half"],[["f","-"],[["f","length"],["w","initial"]],["a",1]]],["w","q"]]]]],[["f","let"],["w","brray:append!"],[["f","lambda"],["w","q"],["w","item"],[["f","do"],[["f","brray:add-to-right!"],["w","q"],["w","item"]],["w","q"]]]],[["f","let"],["w","brray:prepend!"],[["f","lambda"],["w","q"],["w","item"],[["f","do"],[["f","brray:add-to-left!"],["w","q"],["w","item"]],["w","q"]]]],[["f","let"],["w","brray:head!"],[["f","lambda"],["w","q"],[["f","do"],[["f","when"],[["f","="],[["f","brray:offset-right"],["w","q"]],["a",0]],[["f","brray:balance!"],["w","q"]]],[["f","brray:remove-from-right!"],["w","q"]],["w","q"]]]],[["f","let"],["w","brray:tail!"],[["f","lambda"],["w","q"],[["f","do"],[["f","when"],[["f","="],[["f","brray:offset-left"],["w","q"]],["a",0]],[["f","brray:balance!"],["w","q"]]],[["f","brray:remove-from-left!"],["w","q"]],["w","q"]]]],[["f","let"],["w","brray:first"],[["f","lambda"],["w","q"],[["f","brray:get"],["w","q"],["a",0]]]],[["f","let"],["w","brray:last"],[["f","lambda"],["w","q"],[["f","brray:get"],["w","q"],[["f","-"],[["f","brray:length"],["w","q"]],["a",1]]]]],[["f","let"],["w","brray:pop-right!"],[["f","lambda"],["w","q"],[["f","do"],[["f","let"],["w","last"],[["f","brray:last"],["w","q"]]],[["f","brray:head!"],["w","q"]],["w","last"]]]],[["f","let"],["w","brray:pop-left!"],[["f","lambda"],["w","q"],[["f","do"],[["f","let"],["w","first"],[["f","brray:first"],["w","q"]]],[["f","brray:tail!"],["w","q"]],["w","first"]]]],[["f","let"],["w","brray:rotate-left!"],[["f","lambda"],["w","q"],["w","n"],[["f","do"],[["f","let"],["w","N"],[["f","mod"],["w","n"],[["f","brray:length"],["w","q"]]]],[["f","let*"],["w","iter"],[["f","lambda"],["w","index"],["w","bounds"],[["f","do"],[["f","when"],[["f","="],[["f","brray:offset-left"],["w","q"]],["a",0]],[["f","brray:balance!"],["w","q"]]],[["f","brray:add-to-right!"],["w","q"],[["f","brray:first"],["w","q"]]],[["f","brray:remove-from-left!"],["w","q"]],[["f","when"],[["f","<"],["w","index"],["w","bounds"]],[["f","iter"],[["f","+"],["w","index"],["a",1]],["w","bounds"]]]]]],[["f","iter"],["a",0],["w","N"]],["w","q"]]]],[["f","let"],["w","brray:rotate-right!"],[["f","lambda"],["w","q"],["w","n"],[["f","do"],[["f","let"],["w","N"],[["f","mod"],["w","n"],[["f","brray:length"],["w","q"]]]],[["f","let*"],["w","iter"],[["f","lambda"],["w","index"],["w","bounds"],[["f","do"],[["f","when"],[["f","="],[["f","brray:offset-right"],["w","q"]],["a",0]],[["f","brray:balance!"],["w","q"]]],[["f","brray:add-to-left!"],["w","q"],[["f","brray:last"],["w","q"]]],[["f","brray:remove-from-right!"],["w","q"]],[["f","when"],[["f","<"],["w","index"],["w","bounds"]],[["f","iter"],[["f","+"],["w","index"],["a",1]],["w","bounds"]]]]]],[["f","iter"],["a",0],["w","N"]],["w","q"]]]],[["f","let"],["w","cast:array->brray"],[["f","lambda"],["w","initial"],[["f","do"],[["f","let"],["w","q"],[["f","new:brray"]]],[["f","let"],["w","half"],[["f","math:floor"],[["f","*"],[["f","length"],["w","initial"]],["a",0.5]]]],[["f","let*"],["w","left"],[["f","lambda"],["w","index"],[["f","do"],[["f","brray:add-to-left!"],["w","q"],[["f","array:get"],["w","initial"],["w","index"]]],[["f","when"],[["f",">"],["w","index"],["a",0]],[["f","left"],[["f","-"],["w","index"],["a",1]]]]]]],[["f","left"],[["f","-"],["w","half"],["a",1]]],[["f","let*"],["w","rigth"],[["f","lambda"],["w","index"],["w","bounds"],[["f","do"],[["f","brray:add-to-right!"],["w","q"],[["f","array:get"],["w","initial"],["w","index"]]],[["f","when"],[["f","<"],["w","index"],["w","bounds"]],[["f","rigth"],[["f","+"],["w","index"],["a",1]],["w","bounds"]]]]]],[["f","rigth"],["w","half"],[["f","-"],[["f","length"],["w","initial"]],["a",1]]],["w","q"]]]],[["f","let"],["w","brray:slice"],[["f","lambda"],["w","entity"],["w","s"],["w","e"],[["f","do"],[["f","let"],["w","len"],[["f","brray:length"],["w","entity"]]],[["f","let"],["w","start"],[["f","if"],[["f","<"],["w","s"],["a",0]],[["f","math:max"],[["f","+"],["w","len"],["w","s"]],["a",0]],[["f","math:min"],["w","s"],["w","len"]]]],[["f","let"],["w","end"],[["f","if"],[["f","<"],["w","e"],["a",0]],[["f","math:max"],[["f","+"],["w","len"],["w","e"]],["a",0]],[["f","math:min"],["w","e"],["w","len"]]]],[["f","let"],["w","slice"],[["f","new:brray"]]],[["f","let"],["w","slice-len"],[["f","math:max"],[["f","-"],["w","end"],["w","start"]],["a",0]]],[["f","let"],["w","half"],[["f","math:floor"],[["f","*"],["w","slice-len"],["a",0.5]]]],[["f","let*"],["w","left"],[["f","lambda"],["w","index"],[["f","do"],[["f","brray:add-to-left!"],["w","slice"],[["f","brray:get"],["w","entity"],[["f","+"],["w","start"],["w","index"]]]],[["f","when"],[["f",">"],["w","index"],["a",0]],[["f","left"],[["f","-"],["w","index"],["a",1]]]]]]],[["f","left"],[["f","-"],["w","half"],["a",1]]],[["f","let*"],["w","rigth"],[["f","lambda"],["w","index"],["w","bounds"],[["f","do"],[["f","brray:add-to-right!"],["w","slice"],[["f","brray:get"],["w","entity"],[["f","+"],["w","start"],["w","index"]]]],[["f","when"],[["f","<"],["w","index"],["w","bounds"]],[["f","rigth"],[["f","+"],["w","index"],["a",1]],["w","bounds"]]]]]],[["f","rigth"],["w","half"],[["f","-"],["w","slice-len"],["a",1]]],["w","slice"]]]],[["f","let"],["w","date:add-seconds"],[["f","lambda"],["w","date-time"],["w","seconds"],[["f","+"],["w","date-time"],[["f","*"],["w","seconds"],["a",1000]]]]],[["f","let"],["w","date:add-minutes"],[["f","lambda"],["w","date-time"],["w","minutes"],[["f","+"],["w","date-time"],[["f","*"],["w","minutes"],["a",1000],["a",60]]]]],[["f","let"],["w","date:add-hours"],[["f","lambda"],["w","date-time"],["w","hours"],[["f","+"],["w","date-time"],[["f","*"],["w","hours"],["a",1000],["a",60],["a",60]]]]],[["f","let"],["w","date:add-days"],[["f","lambda"],["w","date-time"],["w","days"],[["f","+"],["w","date-time"],[["f","*"],["w","days"],["a",1000],["a",60],["a",60],["a",24]]]]],[["f","let"],["w","date:add-months"],[["f","lambda"],["w","date-time"],["w","months"],[["f","+"],["w","date-time"],[["f","*"],["w","months"],["a",1000],["a",60],["a",60],["a",24],["a",30]]]]],[["f","let"],["w","date:add-years"],[["f","lambda"],["w","date-time"],["w","years"],[["f","+"],["w","date-time"],[["f","*"],["w","years"],["a",1000],["a",60],["a",60],["a",24],["a",365]]]]],[["f","let"],["w","date:sub-seconds"],[["f","lambda"],["w","date-time"],["w","seconds"],[["f","-"],["w","date-time"],[["f","*"],["w","seconds"],["a",1000]]]]],[["f","let"],["w","date:sub-minutes"],[["f","lambda"],["w","date-time"],["w","minutes"],[["f","-"],["w","date-time"],[["f","*"],["w","minutes"],["a",1000],["a",60]]]]],[["f","let"],["w","date:sub-hours"],[["f","lambda"],["w","date-time"],["w","hours"],[["f","-"],["w","date-time"],[["f","*"],["w","hours"],["a",1000],["a",60],["a",60]]]]],[["f","let"],["w","date:sub-days"],[["f","lambda"],["w","date-time"],["w","days"],[["f","-"],["w","date-time"],[["f","*"],["w","days"],["a",1000],["a",60],["a",60],["a",24]]]]],[["f","let"],["w","date:sub-months"],[["f","lambda"],["w","date-time"],["w","months"],[["f","-"],["w","date-time"],[["f","*"],["w","months"],["a",1000],["a",60],["a",60],["a",24],["a",30]]]]],[["f","let"],["w","date:sub-years"],[["f","lambda"],["w","date-time"],["w","years"],[["f","-"],["w","date-time"],[["f","*"],["w","years"],["a",1000],["a",60],["a",60],["a",24],["a",365]]]]],[["f","let"],["w","math:permutations"],[["f","lambda"],["w","xs"],[["f","unless"],[["f","length"],["w","xs"]],[["f","array"],[]],[["f","pi"],["w","xs"],[["f","array:flat-one"]],[["f","array:map"],[["f","lambda"],["w","x"],[["f","pi"],["w","xs"],[["f","array:exclude"],[["f","lambda"],["w","y"],[["f","="],["w","x"],["w","y"]]]],[["f","math:permutations"]],[["f","array:map"],[["f","lambda"],["w","vs"],[["f","array:fold"],["w","vs"],[["f","lambda"],["w","a"],["w","b"],[["f","array:merge!"],["w","a"],["w","b"]]],[["f","array"],["w","x"]]]]]]]]]]]]]
1
+ export default [[[0,"let"],[1,"math:E"],[2,2.718281828459045]],[[0,"let"],[1,"math:PI"],[2,3.141592653589793]],[[0,"let"],[1,"math:range"],[[0,"lambda"],[1,"start"],[1,"end"],[[0,"do"],[[0,"let*"],[1,"iterate"],[[0,"lambda"],[1,"out"],[1,"count"],[[0,"if"],[[0,"<="],[1,"count"],[1,"end"]],[[0,"iterate"],[[0,"array:merge!"],[1,"out"],[[0,"array"],[1,"count"]]],[[0,"+"],[1,"count"],[2,1]]],[1,"out"]]]],[[0,"iterate"],[],[1,"start"]]]]],[[0,"let"],[1,"math:sequence"],[[0,"lambda"],[1,"arr"],[[0,"do"],[[0,"let"],[1,"end"],[[0,"length"],[1,"arr"]]],[[0,"let*"],[1,"iterate"],[[0,"lambda"],[1,"out"],[1,"count"],[[0,"if"],[[0,"<"],[[0,"length"],[1,"out"]],[1,"end"]],[[0,"iterate"],[[0,"array:merge!"],[1,"out"],[[0,"array"],[1,"count"]]],[[0,"+"],[1,"count"],[2,1]]],[1,"out"]]]],[[0,"iterate"],[],[2,0]]]]],[[0,"let"],[1,"math:sequence-n"],[[0,"lambda"],[1,"n"],[[0,"do"],[[0,"let*"],[1,"iterate"],[[0,"lambda"],[1,"out"],[1,"count"],[[0,"if"],[[0,"<"],[[0,"length"],[1,"out"]],[1,"n"]],[[0,"iterate"],[[0,"array:merge!"],[1,"out"],[[0,"array"],[1,"count"]]],[[0,"+"],[1,"count"],[2,1]]],[1,"out"]]]],[[0,"iterate"],[],[2,0]]]]],[[0,"let"],[1,"math:permutations"],[[0,"lambda"],[1,"xs"],[[0,"unless"],[[0,"length"],[1,"xs"]],[[0,"array"],[]],[[0,"pi"],[1,"xs"],[[0,"array:enumerated-map"],[[0,"lambda"],[1,"x"],[1,"i"],[[0,"pi"],[1,"xs"],[[0,"array:enumerated-exclude"],[[0,"lambda"],[1,"."],[1,"j"],[[0,"="],[1,"i"],[1,"j"]]]],[[0,"math:permutations"]],[[0,"array:map"],[[0,"lambda"],[1,"vs"],[[0,"array:merge"],[[0,"array"],[1,"x"]],[1,"vs"]]]]]]],[[0,"array:flat-one"]]]]]],[[0,"let"],[1,"math:greater?"],[[0,"lambda"],[1,"a"],[1,"b"],[[0,">"],[1,"a"],[1,"b"]]]],[[0,"let"],[1,"math:lesser?"],[[0,"lambda"],[1,"a"],[1,"b"],[[0,"<"],[1,"a"],[1,"b"]]]],[[0,"let"],[1,"math:lesser-or-equal?"],[[0,"lambda"],[1,"a"],[1,"b"],[[0,"<="],[1,"a"],[1,"b"]]]],[[0,"let"],[1,"math:greater-or-equal?"],[[0,"lambda"],[1,"a"],[1,"b"],[[0,">="],[1,"a"],[1,"b"]]]],[[0,"let"],[1,"math:equal?"],[[0,"lambda"],[1,"a"],[1,"b"],[[0,"="],[1,"a"],[1,"b"]]]],[[0,"let"],[1,"math:addition"],[[0,"lambda"],[1,"a"],[1,"b"],[[0,"+"],[1,"a"],[1,"b"]]]],[[0,"let"],[1,"math:multiplication"],[[0,"lambda"],[1,"a"],[1,"b"],[[0,"*"],[1,"a"],[1,"b"]]]],[[0,"let"],[1,"math:division"],[[0,"lambda"],[1,"a"],[1,"b"],[[0,"/"],[1,"a"],[1,"b"]]]],[[0,"let"],[1,"math:subtraction"],[[0,"lambda"],[1,"a"],[1,"b"],[[0,"-"],[1,"a"],[1,"b"]]]],[[0,"let"],[1,"math:summation"],[[0,"lambda"],[1,"arr"],[[0,"array:fold"],[1,"arr"],[[0,"safety"],[1,"lambda"],[1,"a"],[1,"b"],[[0,"+"],[1,"a"],[1,"b"]]],[[0,"+"]]]]],[[0,"let"],[1,"math:product"],[[0,"lambda"],[1,"arr"],[[0,"array:fold"],[1,"arr"],[[0,"safety"],[1,"lambda"],[1,"a"],[1,"b"],[[0,"*"],[1,"a"],[1,"b"]]],[[0,"*"]]]]],[[0,"let"],[1,"math:maximum"],[[0,"lambda"],[1,"arr"],[[0,"array:fold"],[1,"arr"],[[0,"safety"],[1,"lambda"],[1,"a"],[1,"b"],[[0,"if"],[[0,">"],[1,"a"],[1,"b"]],[1,"a"],[1,"b"]]],[[0,"car"],[1,"arr"]]]]],[[0,"let"],[1,"math:minimum"],[[0,"lambda"],[1,"arr"],[[0,"array:fold"],[1,"arr"],[[0,"safety"],[1,"lambda"],[1,"a"],[1,"b"],[[0,"if"],[[0,"<"],[1,"a"],[1,"b"]],[1,"a"],[1,"b"]]],[[0,"car"],[1,"arr"]]]]],[[0,"let"],[1,"math:max"],[[0,"lambda"],[1,"a"],[1,"b"],[[0,"if"],[[0,">"],[1,"a"],[1,"b"]],[1,"a"],[1,"b"]]]],[[0,"let"],[1,"math:min"],[[0,"lambda"],[1,"a"],[1,"b"],[[0,"if"],[[0,"<"],[1,"a"],[1,"b"]],[1,"a"],[1,"b"]]]],[[0,"let"],[1,"math:increment"],[[0,"safety"],[1,"lambda"],[1,"i"],[[0,"+"],[1,"i"],[2,1]]]],[[0,"let"],[1,"math:floor"],[[0,"safety"],[1,"lambda"],[1,"n"],[[0,"|"],[1,"n"],[2,0]]]],[[0,"let"],[1,"math:round"],[[0,"safety"],[1,"lambda"],[1,"n"],[[0,"|"],[[0,"+"],[1,"n"],[2,0.5]],[2,0]]]],[[0,"let"],[1,"math:set-bit"],[[0,"safety"],[1,"lambda"],[1,"n"],[1,"bit"],[[0,"|"],[1,"n"],[[0,"<<"],[2,1],[1,"bit"]]]]],[[0,"let"],[1,"math:clear-bit"],[[0,"safety"],[1,"lambda"],[1,"n"],[1,"bit"],[[0,"&"],[1,"n"],[[0,"~"],[[0,"<<"],[2,1],[1,"bit"]]]]]],[[0,"let"],[1,"math:odd-bit?"],[[0,"safety"],[1,"lambda"],[1,"n"],[[0,"="],[[0,"&"],[1,"n"],[2,1]],[2,1]]]],[[0,"let"],[1,"math:average-bit"],[[0,"safety"],[1,"lambda"],[1,"a"],[1,"b"],[[0,">>"],[[0,"+"],[1,"a"],[1,"b"]],[2,1]]]],[[0,"let"],[1,"math:toggle-bit"],[[0,"safety"],[1,"lambda"],[1,"n"],[1,"a"],[1,"b"],[[0,"^"],[1,"a"],[1,"b"],[1,"n"]]]],[[0,"let"],[1,"math:same-sign-bit?"],[[0,"safety"],[1,"lambda"],[1,"a"],[1,"b"],[[0,">="],[[0,"^"],[1,"a"],[1,"b"]],[2,0]]]],[[0,"let"],[1,"math:max-bit"],[[0,"safety"],[1,"lambda"],[1,"a"],[1,"b"],[[0,"-"],[1,"a"],[[0,"&"],[[0,"-"],[1,"a"],[1,"b"]],[[0,">>"],[[0,"-"],[1,"a"],[1,"b"]],[2,31]]]]]],[[0,"let"],[1,"math:min-bit"],[[0,"safety"],[1,"lambda"],[1,"a"],[1,"b"],[[0,"-"],[1,"a"],[[0,"&"],[[0,"-"],[1,"a"],[1,"b"]],[[0,">>"],[[0,"-"],[1,"b"],[1,"a"]],[2,31]]]]]],[[0,"let"],[1,"math:modulo-bit"],[[0,"safety"],[1,"lambda"],[1,"numerator"],[1,"divisor"],[[0,"&"],[1,"numerator"],[[0,"-"],[1,"divisor"],[2,1]]]]],[[0,"let"],[1,"math:n-one-bit?"],[[0,"safety"],[1,"lambda"],[1,"N"],[1,"nth"],[[0,"type"],[[0,"&"],[1,"N"],[[0,"<<"],[2,1],[1,"nth"]]],[1,"boolean"]]]],[[0,"let"],[1,"math:square"],[[0,"safety"],[1,"lambda"],[1,"x"],[[0,"*"],[1,"x"],[1,"x"]]]],[[0,"let"],[1,"math:power"],[[0,"lambda"],[1,"base"],[1,"exp"],[[0,"if"],[[0,"<"],[1,"exp"],[2,0]],[[0,"if"],[[0,"="],[1,"base"],[2,0]],[[0,"throw"],[2,"Attempting to divide by 0 in (math:power)"]],[[0,"/"],[[0,"*"],[1,"base"],[[0,"math:power"],[1,"base"],[[0,"-"],[[0,"*"],[1,"exp"],[2,-1]],[2,1]]]]]],[[0,"cond"],[[0,"="],[1,"exp"],[2,0]],[2,1],[[0,"="],[1,"exp"],[2,1]],[1,"base"],[[0,"*"]],[[0,"*"],[1,"base"],[[0,"math:power"],[1,"base"],[[0,"-"],[1,"exp"],[2,1]]]]]]]],[[0,"let"],[1,"math:greatest-common-divisor"],[[0,"lambda"],[1,"a"],[1,"b"],[[0,"do"],[[0,"let*"],[1,"gcd"],[[0,"lambda"],[1,"a"],[1,"b"],[[0,"if"],[[0,"="],[1,"b"],[2,0]],[1,"a"],[[0,"gcd"],[1,"b"],[[0,"mod"],[1,"a"],[1,"b"]]]]]],[[0,"gcd"],[1,"a"],[1,"b"]]]]],[[0,"let"],[1,"math:least-common-divisor"],[[0,"lambda"],[1,"a"],[1,"b"],[[0,"*"],[1,"a"],[1,"b"],[[0,"/"],[[0,"math:greatest-common-divisor"],[1,"a"],[1,"b"]]]]]],[[0,"let"],[1,"math:sqrt"],[[0,"lambda"],[1,"x"],[[0,"do"],[[0,"let"],[1,"is-good-enough"],[[0,"lambda"],[1,"g"],[1,"x"],[[0,"<"],[[0,"math:abs"],[[0,"-"],[[0,"math:square"],[1,"g"]],[1,"x"]]],[2,0.01]]]],[[0,"let"],[1,"improve-guess"],[[0,"lambda"],[1,"g"],[1,"x"],[[0,"math:average"],[1,"g"],[[0,"*"],[1,"x"],[[0,"/"],[1,"g"]]]]]],[[0,"let*"],[1,"math:sqrt-iter"],[[0,"lambda"],[1,"g"],[1,"x"],[[0,"if"],[[0,"is-good-enough"],[1,"g"],[1,"x"]],[1,"g"],[[0,"math:sqrt-iter"],[[0,"improve-guess"],[1,"g"],[1,"x"]],[1,"x"]]]]],[[0,"math:sqrt-iter"],[2,1],[1,"x"]]]]],[[0,"let"],[1,"math:circumference"],[[0,"lambda"],[1,"radius"],[[0,"*"],[1,"math:PI"],[[0,"*"],[1,"radius"],[2,2]]]]],[[0,"let"],[1,"math:hypotenuse"],[[0,"lambda"],[1,"a"],[1,"b"],[[0,"math:sqrt"],[[0,"+"],[[0,"*"],[1,"a"],[1,"a"]],[[0,"*"],[1,"b"],[1,"b"]]]]]],[[0,"let"],[1,"math:abs"],[[0,"safety"],[1,"lambda"],[1,"n"],[[0,"-"],[[0,"^"],[1,"n"],[[0,">>"],[1,"n"],[2,31]]],[[0,">>"],[1,"n"],[2,31]]]]],[[0,"let"],[1,"math:nth-digit"],[[0,"lambda"],[1,"digit"],[1,"n"],[[0,"|"],[[0,"mod"],[[0,"/"],[1,"digit"],[[0,"math:power"],[2,10],[[0,"-"],[1,"n"],[2,1]]]],[2,10]],[2,0.5]]]],[[0,"let"],[1,"math:normalize"],[[0,"safety"],[1,"lambda"],[1,"value"],[1,"math:min"],[1,"math:max"],[[0,"*"],[[0,"-"],[1,"value"],[1,"math:min"]],[[0,"/"],[[0,"-"],[1,"math:max"],[1,"math:min"]]]]]],[[0,"let"],[1,"math:linear-interpolation"],[[0,"safety"],[1,"lambda"],[1,"a"],[1,"b"],[1,"n"],[[0,"+"],[[0,"*"],[[0,"-"],[2,1],[1,"n"]],[1,"a"]],[[0,"*"],[1,"n"],[1,"b"]]]]],[[0,"let"],[1,"math:gauss-sum"],[[0,"safety"],[1,"lambda"],[1,"n"],[[0,"*"],[1,"n"],[[0,"+"],[1,"n"],[2,1]],[2,0.5]]]],[[0,"let"],[1,"math:gauss-sum-sequance"],[[0,"safety"],[1,"lambda"],[1,"a"],[1,"b"],[[0,"*"],[[0,"+"],[1,"a"],[1,"b"]],[[0,"+"],[[0,"-"],[1,"b"],[1,"a"]],[2,1]],[2,0.5]]]],[[0,"let"],[1,"math:clamp"],[[0,"safety"],[1,"lambda"],[1,"x"],[1,"limit"],[[0,"if"],[[0,">"],[1,"x"],[1,"limit"]],[1,"limit"],[1,"x"]]]],[[0,"let"],[1,"math:odd?"],[[0,"safety"],[1,"lambda"],[1,"x"],[[0,"="],[[0,"mod"],[1,"x"],[2,2]],[2,1]]]],[[0,"let"],[1,"math:even?"],[[0,"safety"],[1,"lambda"],[1,"x"],[[0,"="],[[0,"mod"],[1,"x"],[2,2]],[2,0]]]],[[0,"let"],[1,"math:sign"],[[0,"safety"],[1,"lambda"],[1,"n"],[[0,"if"],[[0,"<"],[1,"n"],[2,0]],[2,-1],[2,1]]]],[[0,"let"],[1,"math:radians"],[[0,"lambda"],[1,"deg"],[[0,"*"],[1,"deg"],[1,"math:PI"],[[0,"/"],[2,180]]]]],[[0,"let"],[1,"math:average"],[[0,"safety"],[1,"lambda"],[1,"x"],[1,"y"],[[0,"*"],[[0,"+"],[1,"x"],[1,"y"]],[2,0.5]]]],[[0,"let"],[1,"math:euclidean-mod"],[[0,"safety"],[1,"lambda"],[1,"a"],[1,"b"],[[0,"mod"],[[0,"+"],[[0,"mod"],[1,"a"],[1,"b"]],[1,"b"]],[1,"b"]]]],[[0,"let"],[1,"math:euclidean-distance"],[[0,"lambda"],[1,"x1"],[1,"y1"],[1,"x2"],[1,"y2"],[[0,"do"],[[0,"let"],[1,"a"],[[0,"-"],[1,"x1"],[1,"x2"]]],[[0,"let"],[1,"b"],[[0,"-"],[1,"y1"],[1,"y2"]]],[[0,"math:sqrt"],[[0,"+"],[[0,"*"],[1,"a"],[1,"a"]],[[0,"*"],[1,"b"],[1,"b"]]]]]]],[[0,"let"],[1,"math:manhattan-distance"],[[0,"lambda"],[1,"x1"],[1,"y1"],[1,"x2"],[1,"y2"],[[0,"+"],[[0,"math:abs"],[[0,"-"],[1,"x2"],[1,"x1"]]],[[0,"math:abs"],[[0,"-"],[1,"y2"],[1,"y1"]]]]]],[[0,"let"],[1,"math:positive?"],[[0,"safety"],[1,"lambda"],[1,"num"],[[0,">"],[1,"num"],[2,0]]]],[[0,"let"],[1,"math:negative?"],[[0,"safety"],[1,"lambda"],[1,"num"],[[0,"<"],[1,"num"],[2,0]]]],[[0,"let"],[1,"math:zero?"],[[0,"safety"],[1,"lambda"],[1,"num"],[[0,"="],[1,"num"],[2,0]]]],[[0,"let"],[1,"math:divisible?"],[[0,"safety"],[1,"lambda"],[1,"a"],[1,"b"],[[0,"="],[[0,"mod"],[1,"a"],[1,"b"]],[2,0]]]],[[0,"let"],[1,"math:ascending?"],[[0,"lambda"],[1,"a"],[1,"b"],[[0,">"],[1,"a"],[1,"b"]]]],[[0,"let"],[1,"math:descending?"],[[0,"lambda"],[1,"a"],[1,"b"],[[0,"<"],[1,"a"],[1,"b"]]]],[[0,"let"],[1,"math:prime?"],[[0,"lambda"],[1,"n"],[[0,"cond"],[[0,"="],[1,"n"],[2,1]],[2,0],[[0,"<"],[1,"n"],[2,0]],[2,0],[[0,"*"]],[[0,"do"],[[0,"let*"],[1,"iter"],[[0,"lambda"],[1,"i"],[1,"end"],[[0,"do"],[[0,"let"],[1,"is-prime"],[[0,"not"],[[0,"="],[[0,"mod"],[1,"n"],[1,"i"]],[2,0]]]],[[0,"if"],[[0,"and"],[[0,"<="],[1,"i"],[1,"end"]],[1,"is-prime"]],[[0,"iter"],[[0,"+"],[1,"i"],[2,1]],[1,"end"]],[1,"is-prime"]]]]],[[0,"or"],[[0,"="],[1,"n"],[2,2]],[[0,"iter"],[2,2],[[0,"math:sqrt"],[1,"n"]]]]]]]],[[0,"let"],[1,"math:largest-power"],[[0,"safety"],[1,"lambda"],[1,"N"],[[0,"do"],[[0,"let"],[1,"N1"],[[0,"|"],[1,"N"],[[0,">>"],[1,"N"],[2,1]]]],[[0,"let"],[1,"N2"],[[0,"|"],[1,"N1"],[[0,">>"],[1,"N1"],[2,2]]]],[[0,"let"],[1,"N3"],[[0,"|"],[1,"N2"],[[0,">>"],[1,"N2"],[2,4]]]],[[0,"let"],[1,"N4"],[[0,"|"],[1,"N3"],[[0,">>"],[1,"N3"],[2,8]]]],[[0,">>"],[[0,"+"],[1,"N4"],[2,1]],[2,1]]]]],[[0,"let"],[1,"math:cartesian-product"],[[0,"lambda"],[1,"a"],[1,"b"],[[0,"array:fold"],[1,"a"],[[0,"lambda"],[1,"p"],[1,"x"],[[0,"array:merge!"],[1,"p"],[[0,"array:map"],[1,"b"],[[0,"lambda"],[1,"y"],[[0,"array"],[1,"x"],[1,"y"]]]]]],[]]]],[[0,"let*"],[1,"array:for"],[[0,"lambda"],[1,"arr"],[1,"callback"],[[0,"when"],[[0,"length"],[1,"arr"]],[[0,"do"],[[0,"callback"],[[0,"car"],[1,"arr"]]],[[0,"array:for"],[[0,"cdr"],[1,"arr"]],[1,"callback"]]]]]],[[0,"let"],[1,"array:map"],[[0,"lambda"],[1,"arr"],[1,"callback"],[[0,"do"],[[0,"let*"],[1,"iterate"],[[0,"lambda"],[1,"arr"],[1,"out"],[[0,"if"],[[0,"length"],[1,"arr"]],[[0,"iterate"],[[0,"cdr"],[1,"arr"]],[[0,"array:merge!"],[1,"out"],[[0,"array"],[[0,"callback"],[[0,"car"],[1,"arr"]]]]]],[1,"out"]]]],[[0,"iterate"],[1,"arr"],[]]]]],[[0,"let"],[1,"array:select"],[[0,"lambda"],[1,"arr"],[1,"callback"],[[0,"do"],[[0,"let*"],[1,"iterate"],[[0,"lambda"],[1,"arr"],[1,"out"],[[0,"if"],[[0,"length"],[1,"arr"]],[[0,"iterate"],[[0,"cdr"],[1,"arr"]],[[0,"if"],[[0,"callback"],[[0,"car"],[1,"arr"]]],[[0,"array:merge!"],[1,"out"],[[0,"array"],[[0,"car"],[1,"arr"]]]],[1,"out"]]],[1,"out"]]]],[[0,"iterate"],[1,"arr"],[]]]]],[[0,"let"],[1,"array:exclude"],[[0,"lambda"],[1,"arr"],[1,"callback"],[[0,"do"],[[0,"let*"],[1,"iterate"],[[0,"lambda"],[1,"arr"],[1,"out"],[[0,"if"],[[0,"length"],[1,"arr"]],[[0,"iterate"],[[0,"cdr"],[1,"arr"]],[[0,"if"],[[0,"not"],[[0,"callback"],[[0,"car"],[1,"arr"]]]],[[0,"array:merge!"],[1,"out"],[[0,"array"],[[0,"car"],[1,"arr"]]]],[1,"out"]]],[1,"out"]]]],[[0,"iterate"],[1,"arr"],[]]]]],[[0,"let"],[1,"array:fold"],[[0,"lambda"],[1,"arr"],[1,"callback"],[1,"initial"],[[0,"do"],[[0,"let*"],[1,"iterate"],[[0,"lambda"],[1,"arr"],[1,"out"],[[0,"if"],[[0,"length"],[1,"arr"]],[[0,"iterate"],[[0,"cdr"],[1,"arr"]],[[0,"callback"],[1,"out"],[[0,"car"],[1,"arr"]]]],[1,"out"]]]],[[0,"iterate"],[1,"arr"],[1,"initial"]]]]],[[0,"let"],[1,"array:every?"],[[0,"lambda"],[1,"arr"],[1,"callback"],[[0,"do"],[[0,"let*"],[1,"iterate"],[[0,"lambda"],[1,"arr"],[[0,"if"],[[0,"and"],[[0,"length"],[1,"arr"]],[[0,"callback"],[[0,"car"],[1,"arr"]]]],[[0,"iterate"],[[0,"cdr"],[1,"arr"]]],[[0,"not"],[[0,"length"],[1,"arr"]]]]]],[[0,"iterate"],[1,"arr"]]]]],[[0,"let"],[1,"array:some?"],[[0,"lambda"],[1,"arr"],[1,"callback"],[[0,"do"],[[0,"let*"],[1,"iterate"],[[0,"lambda"],[1,"arr"],[[0,"if"],[[0,"and"],[[0,"length"],[1,"arr"]],[[0,"not"],[[0,"callback"],[[0,"car"],[1,"arr"]]]]],[[0,"iterate"],[[0,"cdr"],[1,"arr"]]],[[0,"type"],[[0,"length"],[1,"arr"]],[1,"boolean"]]]]],[[0,"iterate"],[1,"arr"]]]]],[[0,"let"],[1,"array:find"],[[0,"lambda"],[1,"arr"],[1,"callback"],[[0,"do"],[[0,"let*"],[1,"iterate"],[[0,"lambda"],[1,"arr"],[[0,"if"],[[0,"length"],[1,"arr"]],[[0,"if"],[[0,"callback"],[[0,"car"],[1,"arr"]]],[[0,"car"],[1,"arr"]],[[0,"iterate"],[[0,"cdr"],[1,"arr"]]]],[]]]],[[0,"iterate"],[1,"arr"]]]]],[[0,"let"],[1,"array:has?"],[[0,"lambda"],[1,"arr"],[1,"callback"],[[0,"do"],[[0,"let*"],[1,"iterate"],[[0,"lambda"],[1,"arr"],[[0,"when"],[[0,"length"],[1,"arr"]],[[0,"if"],[[0,"callback"],[[0,"car"],[1,"arr"]]],[2,1],[[0,"iterate"],[[0,"cdr"],[1,"arr"]]]]]]],[[0,"iterate"],[1,"arr"]]]]],[[0,"let"],[1,"array:reverse"],[[0,"lambda"],[1,"arr"],[[0,"do"],[[0,"let*"],[1,"iterate"],[[0,"lambda"],[1,"arr"],[1,"out"],[[0,"if"],[[0,"length"],[1,"arr"]],[[0,"iterate"],[[0,"cdr"],[1,"arr"]],[[0,"array:merge!"],[[0,"array"],[[0,"car"],[1,"arr"]]],[1,"out"]]],[1,"out"]]]],[[0,"iterate"],[1,"arr"],[]]]]],[[0,"let"],[1,"array:append!"],[[0,"lambda"],[1,"q"],[1,"item"],[[0,"array:set!"],[1,"q"],[[0,"length"],[1,"q"]],[1,"item"]]]],[[0,"let"],[1,"array:tail!"],[[0,"lambda"],[1,"q"],[[0,"array:set!"],[1,"q"],[2,-1]]]],[[0,"let"],[1,"array:push!"],[[0,"lambda"],[1,"q"],[1,"item"],[[0,"do"],[[0,"array:set!"],[1,"q"],[[0,"length"],[1,"q"]],[1,"item"]],[1,"item"]]]],[[0,"let"],[1,"array:pop!"],[[0,"lambda"],[1,"q"],[[0,"do"],[[0,"let"],[1,"l"],[[0,"array:get"],[1,"q"],[2,-1]]],[[0,"array:set!"],[1,"q"],[2,-1]],[1,"l"]]]],[[0,"let"],[1,"array:unique"],[[0,"lambda"],[1,"arr"],[[0,"pi"],[[0,"let"],[1,"sorted"],[[0,"array:sort"],[1,"arr"],[[0,"safety"],[1,"lambda"],[1,"a"],[1,"b"],[[0,">"],[1,"a"],[1,"b"]]]]],[[0,"array:zip"],[[0,"math:sequence"],[1,"sorted"]]],[[0,"array:select"],[[0,"lambda"],[1,"x"],[[0,"or"],[[0,"not"],[[0,"let"],[1,"index"],[[0,"car"],[[0,"cdr"],[1,"x"]]]]],[[0,"not"],[[0,"="],[[0,"array:get"],[1,"sorted"],[[0,"-"],[1,"index"],[2,1]]],[[0,"array:get"],[1,"sorted"],[1,"index"]]]]]]],[[0,"array:map"],[1,"car"]]]]],[[0,"let"],[1,"array:for-range"],[[0,"lambda"],[1,"start"],[1,"end"],[1,"callback"],[[0,"do"],[[0,"let*"],[1,"iterate"],[[0,"lambda"],[1,"i"],[[0,"when"],[[0,"<"],[1,"i"],[1,"end"]],[[0,"do"],[[0,"callback"],[1,"i"]],[[0,"iterate"],[[0,"+"],[1,"i"],[2,1]]]]]]],[[0,"iterate"],[1,"start"]]]]],[[0,"let"],[1,"array:traverse"],[[0,"lambda"],[1,"x"],[1,"callback"],[[0,"if"],[[0,"atom?"],[1,"x"]],[[0,"callback"],[1,"x"]],[[0,"iterate"],[1,"x"],[[0,"lambda"],[1,"y"],[[0,"array:traverse"],[1,"y"],[1,"callback"]]]]]]],[[0,"let"],[1,"array:empty?"],[[0,"safety"],[1,"lambda"],[1,"arr"],[[0,"not"],[[0,"length"],[1,"arr"]]]]],[[0,"let"],[1,"array:count-of"],[[0,"lambda"],[1,"arr"],[1,"callback"],[[0,"pi"],[1,"arr"],[[0,"array:select"],[1,"callback"]],[[0,"length"]]]]],[[0,"let"],[1,"array:empty!"],[[0,"safety"],[1,"lambda"],[1,"arr"],[[0,"do"],[[0,"let*"],[1,"iterate"],[[0,"lambda"],[[0,"if"],[[0,"length"],[1,"arr"]],[[0,"do"],[[0,"array:set!"],[1,"arr"],[2,-1]],[[0,"iterate"]]],[1,"arr"]]]],[[0,"iterate"]]]]],[[0,"let"],[1,"array:in-bounds?"],[[0,"safety"],[1,"lambda"],[1,"arr"],[1,"index"],[[0,"and"],[[0,"<"],[1,"index"],[[0,"length"],[1,"arr"]]],[[0,">="],[1,"index"],[2,0]]]]],[[0,"let"],[1,"array:slice"],[[0,"lambda"],[1,"arr"],[1,"start"],[1,"end"],[[0,"do"],[[0,"let"],[1,"bounds"],[[0,"-"],[1,"end"],[1,"start"]]],[[0,"let*"],[1,"iterate"],[[0,"lambda"],[1,"i"],[1,"out"],[[0,"if"],[[0,"<"],[1,"i"],[1,"bounds"]],[[0,"iterate"],[[0,"+"],[1,"i"],[2,1]],[[0,"array:merge!"],[1,"out"],[[0,"array"],[[0,"array:get"],[1,"arr"],[[0,"+"],[1,"start"],[1,"i"]]]]]],[1,"out"]]]],[[0,"iterate"],[2,0],[]]]]],[[0,"let"],[1,"array:binary-search"],[[0,"lambda"],[1,"arr"],[1,"target"],[[0,"do"],[[0,"let*"],[1,"search"],[[0,"lambda"],[1,"arr"],[1,"target"],[1,"start"],[1,"end"],[[0,"do"],[[0,"when"],[[0,"<="],[1,"start"],[1,"end"]],[[0,"do"],[[0,"let"],[1,"index"],[[0,"math:floor"],[[0,"*"],[[0,"+"],[1,"start"],[1,"end"]],[2,0.5]]]],[[0,"let"],[1,"current"],[[0,"array:get"],[1,"arr"],[1,"index"]]],[[0,"if"],[[0,"="],[1,"target"],[1,"current"]],[1,"target"],[[0,"if"],[[0,">"],[1,"current"],[1,"target"]],[[0,"search"],[1,"arr"],[1,"target"],[1,"start"],[[0,"-"],[1,"index"],[2,1]]],[[0,"search"],[1,"arr"],[1,"target"],[[0,"+"],[1,"index"],[2,1]],[1,"end"]]]]]]]]],[[0,"search"],[1,"arr"],[1,"target"],[2,0],[[0,"length"],[1,"arr"]]]]]],[[0,"let"],[1,"array:zip"],[[0,"lambda"],[1,"A"],[1,"B"],[[0,"do"],[[0,"let*"],[1,"iterate"],[[0,"lambda"],[1,"a"],[1,"b"],[1,"output"],[[0,"if"],[[0,"and"],[[0,"length"],[1,"a"]],[[0,"length"],[1,"b"]]],[[0,"iterate"],[[0,"cdr"],[1,"a"]],[[0,"cdr"],[1,"b"]],[[0,"array:merge!"],[1,"output"],[[0,"array"],[[0,"array"],[[0,"car"],[1,"a"]],[[0,"car"],[1,"b"]]]]]],[1,"output"]]]],[[0,"iterate"],[1,"A"],[1,"B"],[]]]]],[[0,"let"],[1,"array:equal?"],[[0,"lambda"],[1,"a"],[1,"b"],[[0,"or"],[[0,"and"],[[0,"number?"],[1,"a"]],[[0,"number?"],[1,"b"]],[[0,"="],[1,"a"],[1,"b"]]],[[0,"and"],[[0,"string?"],[1,"a"]],[[0,"string?"],[1,"b"]],[[0,"string:equal?"],[1,"a"],[1,"b"]]],[[0,"and"],[[0,"array?"],[1,"a"]],[[0,"="],[[0,"length"],[1,"a"]],[[0,"length"],[1,"b"]]],[[0,"not"],[[0,"array:some?"],[[0,"math:sequence"],[1,"a"]],[[0,"lambda"],[1,"i"],[[0,"not"],[[0,"array:equal?"],[[0,"array:get"],[1,"a"],[1,"i"]],[[0,"array:get"],[1,"b"],[1,"i"]]]]]]]]]]],[[0,"let"],[1,"array:join"],[[0,"lambda"],[1,"arr"],[1,"delim"],[[0,"array:fold"],[[0,"array:zip"],[1,"arr"],[[0,"math:sequence"],[1,"arr"]]],[[0,"lambda"],[1,"a"],[1,"b"],[[0,"if"],[[0,">"],[[0,"car"],[[0,"cdr"],[1,"b"]]],[2,0]],[[0,"string:merge"],[1,"a"],[1,"delim"],[[0,"type"],[[0,"car"],[1,"b"]],[1,"string"]]],[[0,"type"],[[0,"car"],[1,"b"]],[1,"string"]]]],[2,""]]]],[[0,"let"],[1,"array:flat-one"],[[0,"lambda"],[1,"arr"],[[0,"array:fold"],[1,"arr"],[[0,"lambda"],[1,"a"],[1,"b"],[[0,"array:merge!"],[1,"a"],[[0,"if"],[[0,"array?"],[1,"b"]],[1,"b"],[[0,"array"],[1,"b"]]]]],[]]]],[[0,"let"],[1,"array:flat"],[[0,"lambda"],[1,"arr"],[[0,"do"],[[0,"let"],[1,"flatten"],[[0,"lambda"],[1,"item"],[[0,"if"],[[0,"and"],[[0,"array?"],[1,"item"]],[[0,"length"],[1,"item"]]],[[0,"array:fold"],[1,"item"],[[0,"lambda"],[1,"a"],[1,"b"],[[0,"array:merge!"],[1,"a"],[[0,"flatten"],[1,"b"]]]],[]],[[0,"array"],[1,"item"]]]]],[[0,"flatten"],[1,"arr"]]]]],[[0,"let"],[1,"array:sort"],[[0,"lambda"],[1,"arr"],[1,"callback"],[[0,"do"],[[0,"if"],[[0,"<="],[[0,"length"],[1,"arr"]],[2,1]],[1,"arr"],[[0,"do"],[[0,"let"],[1,"pivot"],[[0,"car"],[1,"arr"]]],[[0,"let*"],[1,"iterate"],[[0,"lambda"],[1,"i"],[1,"bounds"],[1,"a"],[1,"b"],[[0,"do"],[[0,"let"],[1,"current"],[[0,"array:get"],[1,"arr"],[1,"i"]]],[[0,"let"],[1,"predicate"],[[0,"callback"],[1,"current"],[1,"pivot"]]],[[0,"let"],[1,"left"],[[0,"if"],[[0,"="],[1,"predicate"],[2,0]],[[0,"array:merge"],[1,"a"],[[0,"array"],[1,"current"]]],[1,"a"]]],[[0,"let"],[1,"right"],[[0,"if"],[[0,"="],[1,"predicate"],[2,1]],[[0,"array:merge"],[1,"b"],[[0,"array"],[1,"current"]]],[1,"b"]]],[[0,"if"],[[0,"<"],[1,"i"],[1,"bounds"]],[[0,"iterate"],[[0,"+"],[1,"i"],[2,1]],[1,"bounds"],[1,"left"],[1,"right"]],[[0,"array"],[1,"left"],[1,"right"]]]]]],[[0,"let"],[1,"sorted"],[[0,"iterate"],[2,1],[[0,"-"],[[0,"length"],[1,"arr"]],[2,1]],[],[]]],[[0,"let"],[1,"left"],[[0,"car"],[1,"sorted"]]],[[0,"let"],[1,"right"],[[0,"car"],[[0,"cdr"],[1,"sorted"]]]],[[0,"array:merge"],[[0,"array:sort"],[1,"left"],[1,"callback"]],[[0,"array"],[1,"pivot"]],[[0,"array:sort"],[1,"right"],[1,"callback"]]]]]]]],[[0,"let"],[1,"array:set"],[[0,"lambda"],[1,"arr"],[1,"index"],[1,"item"],[[0,"array:set!"],[[0,"type"],[1,"arr"],[1,"array"]],[1,"index"],[1,"item"]]]],[[0,"let"],[1,"array:adjacent-difference"],[[0,"lambda"],[1,"arr"],[1,"callback"],[[0,"do"],[[0,"let"],[1,"len"],[[0,"length"],[1,"arr"]]],[[0,"unless"],[[0,"="],[1,"len"],[2,1]],[[0,"do"],[[0,"array"],[[0,"car"],[1,"arr"]]],[[0,"let*"],[1,"iterate"],[[0,"lambda"],[1,"i"],[1,"result"],[[0,"if"],[[0,"<"],[1,"i"],[1,"len"]],[[0,"do"],[[0,"iterate"],[[0,"+"],[1,"i"],[2,1]],[[0,"array:set!"],[1,"result"],[1,"i"],[[0,"callback"],[[0,"array:get"],[1,"arr"],[[0,"-"],[1,"i"],[2,1]]],[[0,"array:get"],[1,"arr"],[1,"i"]]]]]],[1,"result"]]]],[[0,"iterate"],[2,1],[1,"arr"]]],[1,"arr"]]]]],[[0,"let"],[1,"array:adjacent-find"],[[0,"lambda"],[1,"arr"],[1,"callback"],[[0,"do"],[[0,"let"],[1,"len"],[[0,"length"],[1,"arr"]]],[[0,"otherwise"],[[0,"="],[1,"len"],[2,1]],[[0,"do"],[[0,"let*"],[1,"iterate"],[[0,"lambda"],[1,"i"],[[0,"if"],[[0,"<"],[1,"i"],[1,"len"]],[[0,"if"],[[0,"callback"],[[0,"let"],[1,"prev"],[[0,"array:get"],[1,"arr"],[[0,"-"],[1,"i"],[2,1]]]],[[0,"let"],[1,"current"],[[0,"array:get"],[1,"arr"],[1,"i"]]]],[1,"prev"],[[0,"iterate"],[[0,"+"],[1,"i"],[2,1]]]],[]]]],[[0,"iterate"],[2,1]]]]]]],[[0,"let"],[1,"array:adjacent"],[[0,"lambda"],[1,"arr"],[1,"directions"],[1,"y"],[1,"x"],[1,"callback"],[[0,"array:for"],[1,"directions"],[[0,"lambda"],[1,"dir"],[[0,"do"],[[0,"let"],[1,"dy"],[[0,"+"],[[0,"car"],[1,"dir"]],[1,"y"]]],[[0,"let"],[1,"dx"],[[0,"+"],[[0,"car"],[[0,"cdr"],[1,"dir"]]],[1,"x"]]],[[0,"when"],[[0,"and"],[[0,"array:in-bounds?"],[1,"arr"],[1,"dy"]],[[0,"array:in-bounds?"],[[0,"array:get"],[1,"arr"],[1,"dy"]],[1,"dx"]]],[[0,"callback"],[[0,"array:get"],[[0,"array:get"],[1,"arr"],[1,"dy"]],[1,"dx"]],[1,"dir"]]]]]]]],[[0,"let"],[1,"array:partition"],[[0,"lambda"],[1,"arr"],[1,"n"],[[0,"array:fold"],[[0,"array:zip"],[1,"arr"],[[0,"math:sequence"],[1,"arr"]]],[[0,"lambda"],[1,"a"],[1,"b"],[[0,"do"],[[0,"let"],[1,"x"],[[0,"car"],[1,"b"]]],[[0,"let"],[1,"i"],[[0,"car"],[[0,"cdr"],[1,"b"]]]],[[0,"if"],[[0,"mod"],[1,"i"],[1,"n"]],[[0,"array:set!"],[[0,"let"],[1,"last-a"],[[0,"array:get"],[1,"a"],[2,-1]]],[[0,"length"],[1,"last-a"]],[1,"x"]],[[0,"array:set!"],[1,"a"],[[0,"length"],[1,"a"]],[[0,"do"],[[0,"let"],[1,"mut-arr"],[]],[[0,"array:set!"],[1,"mut-arr"],[[0,"length"],[1,"mut-arr"]],[1,"x"]]]]],[1,"a"]]],[]]]],[[0,"let"],[1,"cast:string->chars"],[[0,"safety"],[1,"lambda"],[1,"str"],[[0,"type"],[1,"str"],[1,"array"]]]],[[0,"let"],[1,"cast:chars->string"],[[0,"lambda"],[1,"arr"],[[0,"array:fold"],[1,"arr"],[[0,"safety"],[1,"lambda"],[1,"a"],[1,"x"],[[0,"string:merge"],[1,"a"],[[0,"type"],[1,"x"],[1,"string"]]]],[2,""]]]],[[0,"let"],[1,"cast:string->number"],[[0,"safety"],[1,"lambda"],[1,"str"],[[0,"type"],[1,"str"],[1,"number"]]]],[[0,"let"],[1,"cast:number->string"],[[0,"safety"],[1,"lambda"],[1,"n"],[[0,"type"],[1,"n"],[1,"string"]]]],[[0,"let"],[1,"cast:strings->numbers"],[[0,"lambda"],[1,"arr"],[[0,"array:map"],[1,"arr"],[[0,"safety"],[1,"lambda"],[1,"x"],[[0,"type"],[1,"x"],[1,"number"]]]]]],[[0,"let"],[1,"cast:numbers->strings"],[[0,"lambda"],[1,"arr"],[[0,"array:map"],[1,"arr"],[[0,"safety"],[1,"lambda"],[1,"x"],[[0,"type"],[1,"x"],[1,"string"]]]]]],[[0,"let"],[1,"cast:string->char-codes"],[[0,"lambda"],[1,"str"],[[0,"pi"],[1,"str"],[[0,"type"],[1,"array"]],[[0,"array:map"],[[0,"safety"],[1,"lambda"],[1,"x"],[[0,"type"],[1,"x"],[1,"char-code"]]]]]]],[[0,"let"],[1,"cast:chars->char-codes"],[[0,"lambda"],[1,"arr"],[[0,"pi"],[1,"arr"],[[0,"array:map"],[[0,"safety"],[1,"lambda"],[1,"x"],[[0,"type"],[1,"x"],[1,"char-code"]]]]]]],[[0,"let"],[1,"cast:chars->numbers"],[[0,"lambda"],[1,"arr"],[[0,"pi"],[1,"arr"],[[0,"array:map"],[[0,"safety"],[1,"lambda"],[1,"x"],[[0,"type"],[1,"x"],[1,"number"]]]]]]],[[0,"let"],[1,"cast:char->number"],[[0,"safety"],[1,"lambda"],[1,"ch"],[[0,"type"],[1,"ch"],[1,"number"]]]],[[0,"let"],[1,"cast:char->char-code"],[[0,"safety"],[1,"lambda"],[1,"ch"],[[0,"type"],[1,"ch"],[1,"char-code"]]]],[[0,"let"],[1,"cast:char-code->char"],[[0,"safety"],[1,"lambda"],[1,"ch"],[[0,"type"],[1,"ch"],[1,"char"]]]],[[0,"let"],[1,"cast:char-codes->chars"],[[0,"lambda"],[1,"arr"],[[0,"pi"],[1,"arr"],[[0,"array:map"],[[0,"safety"],[1,"lambda"],[1,"x"],[[0,"type"],[1,"x"],[1,"char"]]]]]]],[[0,"let"],[1,"cast:char-codes->string"],[[0,"lambda"],[1,"arr"],[[0,"pi"],[1,"arr"],[[0,"array:map"],[[0,"safety"],[1,"lambda"],[1,"x"],[[0,"type"],[1,"x"],[1,"char"]]]],[[0,"cast:chars->string"]]]]],[[0,"let"],[1,"string:split"],[[0,"lambda"],[1,"str"],[1,"delim"],[[0,"do"],[[0,"let"],[1,"locals"],[]],[[0,"let"],[1,"delim-arr"],[[0,"type"],[1,"delim"],[1,"array"]]],[[0,"array:set!"],[1,"locals"],[[0,"length"],[1,"locals"]],[1,"delim-arr"]],[[0,"array:set!"],[1,"locals"],[[0,"length"],[1,"locals"]],[[0,"type"],[1,"str"],[1,"array"]]],[[0,"array:set!"],[1,"locals"],[[0,"length"],[1,"locals"]],[[0,"length"],[1,"delim-arr"]]],[[0,"array:set!"],[1,"locals"],[[0,"length"],[1,"locals"]],[2,""]],[[0,"let*"],[1,"iterate"],[[0,"lambda"],[1,"result"],[1,"i"],[1,"bounds"],[[0,"if"],[[0,"<"],[[0,"if"],[[0,"array:every?"],[[0,"array:zip"],[[0,"array:get"],[1,"locals"],[2,0]],[[0,"math:sequence"],[1,"locals"]]],[[0,"lambda"],[1,"item"],[[0,"do"],[[0,"let"],[1,"y"],[[0,"car"],[1,"item"]]],[[0,"let"],[1,"j"],[[0,"car"],[[0,"cdr"],[1,"item"]]]],[[0,"or"],[[0,"<="],[[0,"length"],[[0,"array:get"],[1,"locals"],[2,1]]],[[0,"+"],[1,"i"],[1,"j"]]],[[0,"="],[[0,"type"],[[0,"array:get"],[[0,"array:get"],[1,"locals"],[2,1]],[[0,"+"],[1,"i"],[1,"j"]]],[1,"char-code"]],[[0,"type"],[1,"y"],[1,"char-code"]]]]]]],[[0,"do"],[[0,"array:set!"],[1,"result"],[[0,"length"],[1,"result"]],[[0,"array:get"],[1,"locals"],[2,3]]],[[0,"array:set!"],[1,"locals"],[2,3],[2,""]],[[0,"+"],[1,"i"],[[0,"array:get"],[1,"locals"],[2,2]],[2,-1]]],[[0,"do"],[[0,"array:set!"],[1,"locals"],[2,3],[[0,"string:merge"],[[0,"array:get"],[1,"locals"],[2,3]],[[0,"array:get"],[[0,"array:get"],[1,"locals"],[2,1]],[1,"i"]]]],[1,"i"]]],[1,"bounds"]],[[0,"iterate"],[1,"result"],[[0,"+"],[1,"i"],[2,1]],[1,"bounds"]],[1,"result"]]]],[[0,"array:set!"],[[0,"let"],[1,"iteration-result"],[[0,"iterate"],[],[2,0],[[0,"-"],[[0,"length"],[[0,"array:get"],[1,"locals"],[2,1]]],[2,1]]]],[[0,"length"],[1,"iteration-result"]],[[0,"array:get"],[1,"locals"],[2,3]]]]]],[[0,"let"],[1,"array:shallow-copy"],[[0,"lambda"],[1,"arr"],[[0,"array:fold"],[1,"arr"],[[0,"lambda"],[1,"a"],[1,"b"],[[0,"array:set!"],[1,"a"],[[0,"length"],[1,"a"]],[1,"b"]]],[]]]],[[0,"let"],[1,"array:deep-copy"],[[0,"lambda"],[1,"arr"],[[0,"array:fold"],[1,"arr"],[[0,"lambda"],[1,"a"],[1,"b"],[[0,"array:set!"],[1,"a"],[[0,"length"],[1,"a"]],[[0,"if"],[[0,"array?"],[1,"b"]],[[0,"array:deep-copy"],[1,"b"]],[1,"b"]]]],[]]]],[[0,"let"],[1,"array:merge!"],[[0,"lambda"],[1,"a"],[1,"b"],[[0,"do"],[[0,"array:for"],[1,"b"],[[0,"lambda"],[1,"x"],[[0,"array:set!"],[1,"a"],[[0,"length"],[1,"a"]],[1,"x"]]]],[1,"a"]]]],[[0,"let"],[1,"array:swap-remove!"],[[0,"lambda"],[1,"arr"],[1,"i"],[[0,"do"],[[0,"array:set!"],[1,"arr"],[1,"i"],[[0,"array:get"],[1,"arr"],[[0,"-"],[[0,"length"],[1,"arr"]],[2,1]]]],[[0,"array:set!"],[1,"arr"],[2,-1]]]]],[[0,"let"],[1,"array:index-of"],[[0,"safety"],[1,"lambda"],[1,"arr"],[1,"item"],[[0,"do"],[[0,"let*"],[1,"iterate"],[[0,"lambda"],[1,"arr"],[1,"i"],[[0,"if"],[[0,"length"],[1,"arr"]],[[0,"if"],[[0,"="],[[0,"car"],[1,"arr"]],[1,"item"]],[1,"i"],[[0,"iterate"],[[0,"cdr"],[1,"arr"]],[[0,"+"],[1,"i"],[2,1]]]],[2,-1]]]],[[0,"iterate"],[1,"arr"],[2,0]]]]],[[0,"let"],[1,"array:enumerate"],[[0,"lambda"],[1,"arr"],[[0,"array:zip"],[[0,"math:sequence"],[1,"arr"]],[1,"arr"]]]],[[0,"let"],[1,"array:enumerated-map"],[[0,"lambda"],[1,"arr"],[1,"callback"],[[0,"do"],[[0,"let*"],[1,"iterate"],[[0,"lambda"],[1,"arr"],[1,"i"],[1,"out"],[[0,"if"],[[0,"length"],[1,"arr"]],[[0,"iterate"],[[0,"cdr"],[1,"arr"]],[[0,"+"],[1,"i"],[2,1]],[[0,"array:merge!"],[1,"out"],[[0,"array"],[[0,"callback"],[[0,"car"],[1,"arr"]],[1,"i"]]]]],[1,"out"]]]],[[0,"iterate"],[1,"arr"],[2,0],[]]]]],[[0,"let"],[1,"array:enumerated-select"],[[0,"lambda"],[1,"arr"],[1,"callback"],[[0,"do"],[[0,"let*"],[1,"iterate"],[[0,"lambda"],[1,"arr"],[1,"i"],[1,"out"],[[0,"if"],[[0,"length"],[1,"arr"]],[[0,"iterate"],[[0,"cdr"],[1,"arr"]],[[0,"+"],[1,"i"],[2,1]],[[0,"if"],[[0,"callback"],[[0,"car"],[1,"arr"]],[1,"i"]],[[0,"array:merge!"],[1,"out"],[[0,"array"],[[0,"car"],[1,"arr"]]]],[1,"out"]]],[1,"out"]]]],[[0,"iterate"],[1,"arr"],[2,0],[]]]]],[[0,"let"],[1,"array:enumerated-exclude"],[[0,"lambda"],[1,"arr"],[1,"callback"],[[0,"do"],[[0,"let*"],[1,"iterate"],[[0,"lambda"],[1,"arr"],[1,"i"],[1,"out"],[[0,"if"],[[0,"length"],[1,"arr"]],[[0,"iterate"],[[0,"cdr"],[1,"arr"]],[[0,"+"],[1,"i"],[2,1]],[[0,"if"],[[0,"not"],[[0,"callback"],[[0,"car"],[1,"arr"]],[1,"i"]]],[[0,"array:merge!"],[1,"out"],[[0,"array"],[[0,"car"],[1,"arr"]]]],[1,"out"]]],[1,"out"]]]],[[0,"iterate"],[1,"arr"],[2,0],[]]]]],[[0,"let"],[1,"array:enumerated-fold"],[[0,"lambda"],[1,"arr"],[1,"callback"],[1,"initial"],[[0,"do"],[[0,"let*"],[1,"iterate"],[[0,"lambda"],[1,"arr"],[1,"i"],[1,"out"],[[0,"if"],[[0,"length"],[1,"arr"]],[[0,"iterate"],[[0,"cdr"],[1,"arr"]],[[0,"+"],[1,"i"],[2,1]],[[0,"callback"],[1,"out"],[[0,"car"],[1,"arr"]],[1,"i"]]],[1,"out"]]]],[[0,"iterate"],[1,"arr"],[2,0],[1,"initial"]]]]],[[0,"let"],[1,"array:find-index"],[[0,"safety"],[1,"lambda"],[1,"arr"],[1,"callback"],[[0,"do"],[[0,"let*"],[1,"iterate"],[[0,"lambda"],[1,"arr"],[1,"i"],[[0,"if"],[[0,"length"],[1,"arr"]],[[0,"if"],[[0,"callback"],[[0,"car"],[1,"arr"]]],[1,"i"],[[0,"iterate"],[[0,"cdr"],[1,"arr"]],[[0,"+"],[1,"i"],[2,1]]]],[2,-1]]]],[[0,"iterate"],[1,"arr"],[2,0]]]]],[[0,"let"],[1,"array:remove"],[[0,"lambda"],[1,"arr"],[1,"i"],[[0,"array:fold"],[1,"arr"],[[0,"lambda"],[1,"a"],[1,"x"],[[0,"do"],[[0,"unless"],[[0,"="],[1,"x"],[1,"i"]],[[0,"array:merge!"],[1,"a"],[[0,"array"],[1,"x"]]],[1,"a"]]]],[]]]],[[0,"let"],[1,"array:pad-right"],[[0,"lambda"],[1,"a"],[1,"b"],[[0,"if"],[[0,">"],[[0,"length"],[1,"a"]],[[0,"length"],[1,"b"]]],[[0,"array:merge"],[1,"b"],[[0,"array"],[[0,"-"],[[0,"length"],[1,"a"]],[[0,"length"],[1,"b"]]],[1,"length"]]],[[0,"array:merge"],[1,"a"],[[0,"array"],[[0,"-"],[[0,"length"],[1,"b"]],[[0,"length"],[1,"a"]]],[1,"length"]]]]]],[[0,"let"],[1,"array:pad-left"],[[0,"lambda"],[1,"a"],[1,"b"],[[0,"if"],[[0,">"],[[0,"length"],[1,"a"]],[[0,"length"],[1,"b"]]],[[0,"array:merge"],[[0,"array"],[[0,"-"],[[0,"length"],[1,"a"]],[[0,"length"],[1,"b"]]],[1,"length"]],[1,"b"]],[[0,"array:merge"],[[0,"array"],[[0,"-"],[[0,"length"],[1,"b"]],[[0,"length"],[1,"a"]]],[1,"length"]],[1,"a"]]]]],[[0,"let"],[1,"array:pad-right!"],[[0,"lambda"],[1,"a"],[1,"b"],[[0,"if"],[[0,">"],[[0,"length"],[1,"a"]],[[0,"length"],[1,"b"]]],[[0,"array:merge!"],[1,"b"],[[0,"array"],[[0,"-"],[[0,"length"],[1,"a"]],[[0,"length"],[1,"b"]]],[1,"length"]]],[[0,"array:merge!"],[1,"a"],[[0,"array"],[[0,"-"],[[0,"length"],[1,"b"]],[[0,"length"],[1,"a"]]],[1,"length"]]]]]],[[0,"let"],[1,"array:pad-left!"],[[0,"lambda"],[1,"a"],[1,"b"],[[0,"if"],[[0,">"],[[0,"length"],[1,"a"]],[[0,"length"],[1,"b"]]],[[0,"array:merge!"],[[0,"array"],[[0,"-"],[[0,"length"],[1,"a"]],[[0,"length"],[1,"b"]]],[1,"length"]],[1,"b"]],[[0,"array:merge!"],[[0,"array"],[[0,"-"],[[0,"length"],[1,"b"]],[[0,"length"],[1,"a"]]],[1,"length"]],[1,"a"]]]]],[[0,"let"],[1,"array:rotate-right"],[[0,"lambda"],[1,"arr"],[1,"n"],[[0,"pi"],[1,"arr"],[[0,"array:zip"],[[0,"math:sequence"],[1,"arr"]]],[[0,"array:fold"],[[0,"lambda"],[1,"a"],[1,"b"],[[0,"array:set!"],[1,"a"],[[0,"mod"],[[0,"+"],[[0,"car"],[[0,"cdr"],[1,"b"]]],[1,"n"]],[[0,"length"],[1,"arr"]]],[[0,"car"],[1,"b"]]]],[[0,"array"],[[0,"length"],[1,"arr"]],[1,"length"]]]]]],[[0,"let"],[1,"array:rotate-left"],[[0,"lambda"],[1,"arr"],[1,"n"],[[0,"pi"],[1,"arr"],[[0,"array:zip"],[[0,"math:sequence"],[1,"arr"]]],[[0,"array:fold"],[[0,"lambda"],[1,"a"],[1,"b"],[[0,"array:set!"],[1,"a"],[[0,"mod"],[[0,"+"],[[0,"car"],[[0,"cdr"],[1,"b"]]],[[0,"-"],[[0,"length"],[1,"arr"]],[1,"n"]]],[[0,"length"],[1,"arr"]]],[[0,"car"],[1,"b"]]]],[[0,"array"],[[0,"length"],[1,"arr"]],[1,"length"]]]]]],[[0,"let"],[1,"array:first"],[[0,"safety"],[1,"lambda"],[1,"arr"],[[0,"array:get"],[1,"arr"],[2,0]]]],[[0,"let"],[1,"array:last"],[[0,"safety"],[1,"lambda"],[1,"arr"],[[0,"array:get"],[1,"arr"],[2,-1]]]],[[0,"let"],[1,"string:index-of-char"],[[0,"lambda"],[1,"str"],[1,"character"],[[0,"do"],[[0,"let*"],[1,"iterate"],[[0,"lambda"],[1,"arr"],[1,"i"],[[0,"if"],[[0,"length"],[1,"arr"]],[[0,"if"],[[0,"string:equal?"],[[0,"car"],[1,"arr"]],[1,"character"]],[1,"i"],[[0,"iterate"],[[0,"cdr"],[1,"arr"]],[[0,"+"],[1,"i"],[2,1]]]],[2,-1]]]],[[0,"iterate"],[[0,"type"],[1,"str"],[1,"array"]],[2,0]]]]],[[0,"let"],[1,"string:match"],[[0,"lambda"],[1,"str"],[1,"word"],[[0,"do"],[[0,"let"],[1,"string-arr"],[[0,"type"],[1,"str"],[1,"array"]]],[[0,"let*"],[1,"iterate"],[[0,"lambda"],[1,"arr"],[1,"i"],[[0,"if"],[[0,"length"],[1,"arr"]],[[0,"if"],[[0,"string:equal?"],[[0,"pi"],[1,"string-arr"],[[0,"array:slice"],[1,"i"],[[0,"+"],[1,"i"],[[0,"length"],[1,"word"]]]],[[0,"array:join"],[2,""]]],[1,"word"]],[1,"i"],[[0,"iterate"],[[0,"cdr"],[1,"arr"]],[[0,"+"],[1,"i"],[2,1]]]],[2,-1]]]],[[0,"iterate"],[1,"toArr"],[2,0]]]]],[[0,"let"],[1,"string:greater?"],[[0,"lambda"],[1,"L"],[1,"R"],[[0,"otherwise"],[[0,"string:equal?"],[1,"L"],[1,"R"]],[[0,"do"],[[0,"let"],[1,"A"],[[0,"cast:string->char-codes"],[[0,"type"],[1,"L"],[1,"string"]]]],[[0,"let"],[1,"B"],[[0,"cast:string->char-codes"],[[0,"type"],[1,"R"],[1,"string"]]]],[[0,"let"],[1,"a"],[[0,"if"],[[0,"<"],[[0,"length"],[1,"A"]],[[0,"length"],[1,"B"]]],[[0,"array:merge!"],[1,"A"],[[0,"array"],[[0,"-"],[[0,"length"],[1,"B"]],[[0,"length"],[1,"A"]]],[1,"length"]]],[1,"A"]]],[[0,"let"],[1,"b"],[[0,"if"],[[0,">"],[[0,"length"],[1,"A"]],[[0,"length"],[1,"B"]]],[[0,"array:merge!"],[1,"B"],[[0,"array"],[[0,"-"],[[0,"length"],[1,"A"]],[[0,"length"],[1,"B"]]],[1,"length"]]],[1,"B"]]],[[0,"pi"],[1,"a"],[[0,"array:zip"],[1,"b"]],[[0,"array:fold"],[[0,"lambda"],[1,"acc"],[1,"pair"],[[0,"if"],[[0,">"],[[0,"car"],[1,"pair"]],[[0,"car"],[[0,"cdr"],[1,"pair"]]]],[2,0],[1,"acc"]]],[2,1]]]]]]],[[0,"let"],[1,"string:lesser?"],[[0,"lambda"],[1,"L"],[1,"R"],[[0,"otherwise"],[[0,"string:equal?"],[1,"L"],[1,"R"]],[[0,"do"],[[0,"let"],[1,"A"],[[0,"cast:string->char-codes"],[[0,"type"],[1,"L"],[1,"string"]]]],[[0,"let"],[1,"B"],[[0,"cast:string->char-codes"],[[0,"type"],[1,"R"],[1,"string"]]]],[[0,"let"],[1,"a"],[[0,"if"],[[0,"<"],[[0,"length"],[1,"A"]],[[0,"length"],[1,"B"]]],[[0,"array:merge!"],[1,"A"],[[0,"array"],[[0,"-"],[[0,"length"],[1,"B"]],[[0,"length"],[1,"A"]]],[1,"length"]]],[1,"A"]]],[[0,"let"],[1,"b"],[[0,"if"],[[0,">"],[[0,"length"],[1,"A"]],[[0,"length"],[1,"B"]]],[[0,"array:merge!"],[1,"B"],[[0,"array"],[[0,"-"],[[0,"length"],[1,"A"]],[[0,"length"],[1,"B"]]],[1,"length"]]],[1,"B"]]],[[0,"pi"],[1,"a"],[[0,"array:zip"],[1,"b"]],[[0,"array:fold"],[[0,"lambda"],[1,"acc"],[1,"pair"],[[0,"if"],[[0,"<"],[[0,"car"],[1,"pair"]],[[0,"car"],[[0,"cdr"],[1,"pair"]]]],[2,0],[1,"acc"]]],[2,1]]]]]]],[[0,"let"],[1,"string:equal?"],[[0,"lambda"],[1,"L"],[1,"R"],[[0,"when"],[[0,"="],[[0,"length"],[1,"L"]],[[0,"length"],[1,"R"]]],[[0,"do"],[[0,"let"],[1,"a"],[[0,"cast:string->char-codes"],[1,"R"]]],[[0,"let"],[1,"b"],[[0,"cast:string->char-codes"],[1,"L"]]],[[0,"pi"],[1,"a"],[[0,"array:zip"],[1,"b"]],[[0,"array:every?"],[[0,"lambda"],[1,"x"],[[0,"="],[[0,"car"],[1,"x"]],[[0,"car"],[[0,"cdr"],[1,"x"]]]]]]]]]]],[[0,"let"],[1,"string:trim-left"],[[0,"lambda"],[1,"str"],[[0,"do"],[[0,"let"],[1,"tr"],[[0,"array"],[2,1]]],[[0,"pi"],[1,"str"],[[0,"type"],[1,"array"]],[[0,"array:fold"],[[0,"lambda"],[1,"a"],[1,"b"],[[0,"if"],[[0,"and"],[[0,"car"],[1,"tr"]],[[0,"string:equal?"],[1,"b"],[2," "]]],[1,"a"],[[0,"do"],[[0,"when"],[[0,"car"],[1,"tr"]],[[0,"array:set!"],[1,"tr"],[2,0],[2,0]]],[[0,"string:merge"],[1,"a"],[1,"b"]]]]],[2,""]]]]]],[[0,"let"],[1,"string:trim-right"],[[0,"lambda"],[1,"str"],[[0,"do"],[[0,"let"],[1,"tr"],[[0,"array"],[2,1]]],[[0,"pi"],[1,"str"],[[0,"type"],[1,"array"]],[[0,"array:reverse"]],[[0,"array:fold"],[[0,"lambda"],[1,"a"],[1,"b"],[[0,"if"],[[0,"and"],[[0,"car"],[1,"tr"]],[[0,"string:equal?"],[1,"b"],[2," "]]],[1,"a"],[[0,"do"],[[0,"when"],[[0,"car"],[1,"tr"]],[[0,"array:set!"],[1,"tr"],[2,0],[2,0]]],[[0,"string:merge"],[1,"b"],[1,"a"]]]]],[2,""]]]]]],[[0,"let"],[1,"string:trim"],[[0,"lambda"],[1,"str"],[[0,"pi"],[1,"str"],[[0,"string:trim-left"]],[[0,"string:trim-right"]]]]],[[0,"let"],[1,"string:lines"],[[0,"lambda"],[1,"str"],[[0,"pi"],[1,"str"],[[0,"type"],[1,"array"]],[[0,"array:fold"],[[0,"lambda"],[1,"a"],[1,"b"],[[0,"do"],[[0,"let"],[1,"prev"],[[0,"array:get"],[1,"a"],[2,-1]]],[[0,"if"],[[0,"string:equal?"],[1,"b"],[2,"\n"]],[[0,"array:set!"],[1,"a"],[[0,"length"],[1,"a"]],[]],[[0,"array:set!"],[1,"prev"],[[0,"length"],[1,"prev"]],[1,"b"]]],[1,"a"]]],[[0,"array"],[]]],[[0,"array:map"],[[0,"lambda"],[1,"x"],[[0,"array:join"],[1,"x"],[2,""]]]]]]],[[0,"let"],[1,"string:words"],[[0,"lambda"],[1,"str"],[[0,"pi"],[1,"str"],[[0,"type"],[1,"array"]],[[0,"array:fold"],[[0,"lambda"],[1,"a"],[1,"b"],[[0,"do"],[[0,"let"],[1,"prev"],[[0,"array:get"],[1,"a"],[2,-1]]],[[0,"if"],[[0,"string:equal?"],[1,"b"],[2," "]],[[0,"array:set!"],[1,"a"],[[0,"length"],[1,"a"]],[]],[[0,"array:set!"],[1,"prev"],[[0,"length"],[1,"prev"]],[1,"b"]]],[1,"a"]]],[[0,"array"],[]]],[[0,"array:map"],[[0,"lambda"],[1,"x"],[[0,"array:join"],[1,"x"],[2,""]]]]]]],[[0,"let"],[1,"string:separator"],[[0,"lambda"],[1,"str"],[1,"separator"],[[0,"pi"],[1,"str"],[[0,"type"],[1,"array"]],[[0,"array:fold"],[[0,"lambda"],[1,"a"],[1,"b"],[[0,"do"],[[0,"let"],[1,"prev"],[[0,"array:get"],[1,"a"],[2,-1]]],[[0,"if"],[[0,"string:equal?"],[1,"b"],[1,"separator"]],[[0,"array:set!"],[1,"a"],[[0,"length"],[1,"a"]],[]],[[0,"array:set!"],[1,"prev"],[[0,"length"],[1,"prev"]],[1,"b"]]],[1,"a"]]],[[0,"array"],[]]],[[0,"array:map"],[[0,"lambda"],[1,"x"],[[0,"array:join"],[1,"x"],[2,""]]]]]]],[[0,"let"],[1,"new:set"],[[0,"lambda"],[1,"items"],[[0,"set:add!"],[[0,"array"],[],[],[],[]],[1,"items"]]]],[[0,"let"],[1,"new:array"],[[0,"safety"],[1,"lambda"],[1,"items"],[[0,"type"],[1,"items"],[1,"array"]]]],[[0,"let"],[1,"new:list"],[[0,"safety"],[1,"lambda"],[1,"value"],[[0,"array"],[],[1,"value"],[]]]],[[0,"let"],[1,"new:binary-tree"],[[0,"safety"],[1,"lambda"],[1,"value"],[[0,"do"],[[0,"let"],[1,"arr"],[]],[[0,"array:set!"],[1,"arr"],[2,0],[1,"value"]],[[0,"array:set!"],[1,"arr"],[2,1],[]],[[0,"array:set!"],[1,"arr"],[2,2],[]],[1,"arr"]]]],[[0,"let"],[1,"binary-tree:left"],[[0,"safety"],[1,"lambda"],[1,"node"],[[0,"array:get"],[1,"node"],[2,1]]]],[[0,"let"],[1,"binary-tree:right"],[[0,"safety"],[1,"lambda"],[1,"node"],[[0,"array:get"],[1,"node"],[2,2]]]],[[0,"let"],[1,"binary-tree:left!"],[[0,"safety"],[1,"lambda"],[1,"tree"],[1,"node"],[[0,"array:set!"],[1,"tree"],[2,1],[1,"node"]]]],[[0,"let"],[1,"binary-tree:right!"],[[0,"safety"],[1,"lambda"],[1,"tree"],[1,"node"],[[0,"array:set!"],[1,"tree"],[2,2],[1,"node"]]]],[[0,"let"],[1,"binary-tree:value"],[[0,"safety"],[1,"lambda"],[1,"node"],[[0,"car"],[1,"node"]]]],[[0,"let"],[1,"set:index"],[[0,"lambda"],[1,"table"],[1,"key"],[[0,"do"],[[0,"let"],[1,"prime-num"],[2,31]],[[0,"let"],[1,"key-arr"],[[0,"type"],[[0,"type"],[1,"key"],[1,"string"]],[1,"array"]]],[[0,"let"],[1,"total"],[[0,"array"],[2,0]]],[[0,"let*"],[1,"find-hash-index"],[[0,"lambda"],[1,"i"],[1,"bounds"],[[0,"do"],[[0,"let"],[1,"letter"],[[0,"array:get"],[1,"key-arr"],[1,"i"]]],[[0,"let"],[1,"value"],[[0,"-"],[[0,"type"],[1,"letter"],[1,"char-code"]],[2,96]]],[[0,"array:set!"],[1,"total"],[2,0],[[0,"math:euclidean-mod"],[[0,"+"],[[0,"*"],[[0,"car"],[1,"total"]],[1,"prime-num"]],[1,"value"]],[[0,"length"],[1,"table"]]]],[[0,"if"],[[0,"<"],[1,"i"],[1,"bounds"]],[[0,"find-hash-index"],[[0,"+"],[1,"i"],[2,1]],[1,"bounds"]],[[0,"car"],[1,"total"]]]]]],[[0,"find-hash-index"],[2,0],[[0,"if"],[[0,"<"],[[0,"-"],[[0,"length"],[1,"key-arr"]],[2,1]],[2,100]],[[0,"-"],[[0,"length"],[1,"key-arr"]],[2,1]],[2,100]]]]]],[[0,"let"],[1,"set:add!"],[[0,"lambda"],[1,"table"],[1,"key"],[[0,"do"],[[0,"let"],[1,"idx"],[[0,"set:index"],[1,"table"],[1,"key"]]],[[0,"otherwise"],[[0,"array:in-bounds?"],[1,"table"],[1,"idx"]],[[0,"array:set!"],[1,"table"],[1,"idx"],[[0,"array"]]]],[[0,"let"],[1,"current"],[[0,"array:get"],[1,"table"],[1,"idx"]]],[[0,"let"],[1,"len"],[[0,"length"],[1,"current"]]],[[0,"let"],[1,"index"],[[0,"if"],[1,"len"],[[0,"array:find-index"],[1,"current"],[[0,"lambda"],[1,"x"],[[0,"string:equal?"],[[0,"type"],[1,"x"],[1,"string"]],[[0,"type"],[1,"key"],[1,"string"]]]]],[2,-1]]],[[0,"let"],[1,"entry"],[1,"key"]],[[0,"if"],[[0,"="],[1,"index"],[2,-1]],[[0,"array:set!"],[1,"current"],[[0,"length"],[1,"current"]],[1,"entry"]],[[0,"array:set!"],[1,"current"],[1,"index"],[1,"entry"]]],[1,"table"]]]],[[0,"let"],[1,"set:remove!"],[[0,"lambda"],[1,"table"],[1,"key"],[[0,"do"],[[0,"let"],[1,"idx"],[[0,"set:index"],[1,"table"],[1,"key"]]],[[0,"otherwise"],[[0,"array:in-bounds?"],[1,"table"],[1,"idx"]],[[0,"array:set!"],[1,"table"],[1,"idx"],[[0,"Array"]]]],[[0,"let"],[1,"current"],[[0,"array:get"],[1,"table"],[1,"idx"]]],[[0,"let"],[1,"len"],[[0,"length"],[1,"current"]]],[[0,"let"],[1,"index"],[[0,"if"],[1,"len"],[[0,"array:find-index"],[1,"current"],[[0,"lambda"],[1,"x"],[[0,"string:equal?"],[[0,"type"],[1,"x"],[1,"string"]],[[0,"type"],[1,"key"],[1,"string"]]]]],[2,-1]]],[[0,"let"],[1,"entry"],[1,"key"]],[[0,"otherwise"],[[0,"="],[1,"index"],[2,-1]],[[0,"and"],[[0,"array:set!"],[1,"current"],[1,"index"],[[0,"array:get"],[1,"current"],[2,-1]]],[[0,"array:set!"],[1,"current"],[2,-1]]]],[1,"table"]]]],[[0,"let"],[1,"set:has?"],[[0,"lambda"],[1,"table"],[1,"key"],[[0,"and"],[[0,"array:in-bounds?"],[1,"table"],[[0,"let"],[1,"idx"],[[0,"set:index"],[1,"table"],[1,"key"]]]],[[0,"and"],[[0,"length"],[[0,"let"],[1,"current"],[[0,"array:get"],[1,"table"],[1,"idx"]]]],[[0,">="],[[0,"array:find-index"],[1,"current"],[[0,"lambda"],[1,"x"],[[0,"string:equal?"],[[0,"type"],[1,"x"],[1,"string"]],[[0,"type"],[1,"key"],[1,"string"]]]]],[2,0]]]]]],[[0,"let"],[1,"set:intersection"],[[0,"lambda"],[1,"a"],[1,"b"],[[0,"pi"],[1,"b"],[[0,"cast:table->array"]],[[0,"array:fold"],[[0,"lambda"],[1,"out"],[1,"element"],[[0,"do"],[[0,"when"],[[0,"set:has?"],[1,"a"],[1,"element"]],[[0,"set:add!"],[1,"out"],[1,"element"]]],[1,"out"]]],[[0,"array"],[],[],[],[],[]]]]]],[[0,"let"],[1,"set:difference"],[[0,"lambda"],[1,"a"],[1,"b"],[[0,"pi"],[1,"a"],[[0,"cast:table->array"]],[[0,"array:fold"],[[0,"lambda"],[1,"out"],[1,"element"],[[0,"do"],[[0,"when"],[[0,"not"],[[0,"set:has?"],[1,"b"],[1,"element"]]],[[0,"set:add!"],[1,"out"],[1,"element"]]],[1,"out"]]],[[0,"array"],[],[],[],[],[]]]]]],[[0,"let"],[1,"set:xor"],[[0,"lambda"],[1,"a"],[1,"b"],[[0,"do"],[[0,"let"],[1,"out"],[[0,"array"],[],[],[],[],[]]],[[0,"pi"],[1,"a"],[[0,"cast:table->array"]],[[0,"array:for"],[[0,"lambda"],[1,"element"],[[0,"when"],[[0,"not"],[[0,"set:has?"],[1,"b"],[1,"element"]]],[[0,"set:add!"],[1,"out"],[1,"element"]]]]]],[[0,"pi"],[1,"b"],[[0,"cast:table->array"]],[[0,"array:for"],[[0,"lambda"],[1,"element"],[[0,"when"],[[0,"not"],[[0,"set:has?"],[1,"a"],[1,"element"]]],[[0,"set:add!"],[1,"out"],[1,"element"]]]]]],[1,"out"]]]],[[0,"let"],[1,"set:union"],[[0,"lambda"],[1,"a"],[1,"b"],[[0,"do"],[[0,"let"],[1,"out"],[[0,"array"],[],[],[],[],[]]],[[0,"pi"],[1,"a"],[[0,"cast:table->array"]],[[0,"array:for"],[[0,"lambda"],[1,"element"],[[0,"set:add!"],[1,"out"],[1,"element"]]]]],[[0,"pi"],[1,"b"],[[0,"cast:table->array"]],[[0,"array:for"],[[0,"lambda"],[1,"element"],[[0,"set:add!"],[1,"out"],[1,"element"]]]]],[1,"out"]]]],[[0,"let"],[1,"cast:table->array"],[[0,"lambda"],[1,"set"],[[0,"array:select"],[[0,"array:flat"],[1,"set"]],[1,"atom?"]]]],[[0,"let"],[1,"set:empty!"],[[0,"lambda"],[1,"table"],[[0,"array:map"],[1,"table"],[1,"empty!"]]]],[[0,"let"],[1,"map:empty!"],[[0,"lambda"],[1,"table"],[[0,"array:map"],[1,"table"],[1,"empty!"]]]],[[0,"let"],[1,"map:set!"],[[0,"lambda"],[1,"table"],[1,"key"],[1,"value"],[[0,"do"],[[0,"let"],[1,"idx"],[[0,"set:index"],[1,"table"],[1,"key"]]],[[0,"otherwise"],[[0,"array:in-bounds?"],[1,"table"],[1,"idx"]],[[0,"array:set!"],[1,"table"],[1,"idx"],[]]],[[0,"let"],[1,"current"],[[0,"array:get"],[1,"table"],[1,"idx"]]],[[0,"let"],[1,"len"],[[0,"length"],[1,"current"]]],[[0,"let"],[1,"index"],[[0,"if"],[1,"len"],[[0,"array:find-index"],[1,"current"],[[0,"lambda"],[1,"x"],[[0,"string:equal?"],[[0,"type"],[[0,"car"],[1,"x"]],[1,"string"]],[[0,"type"],[1,"key"],[1,"string"]]]]],[2,-1]]],[[0,"let"],[1,"entry"],[[0,"array"],[1,"key"],[1,"value"]]],[[0,"if"],[[0,"="],[1,"index"],[2,-1]],[[0,"array:set!"],[1,"current"],[[0,"length"],[1,"current"]],[1,"entry"]],[[0,"array:set!"],[1,"current"],[1,"index"],[1,"entry"]]],[1,"table"]]]],[[0,"let"],[1,"map:remove!"],[[0,"lambda"],[1,"table"],[1,"key"],[[0,"do"],[[0,"let"],[1,"idx"],[[0,"set:index"],[1,"table"],[1,"key"]]],[[0,"otherwise"],[[0,"array:in-bounds?"],[1,"table"],[1,"idx"]],[[0,"array:set!"],[1,"table"],[1,"idx"],[]]],[[0,"let"],[1,"current"],[[0,"array:get"],[1,"table"],[1,"idx"]]],[[0,"let"],[1,"len"],[[0,"length"],[1,"current"]]],[[0,"let"],[1,"index"],[[0,"if"],[1,"len"],[[0,"array:find-index"],[1,"current"],[[0,"lambda"],[1,"x"],[[0,"string:equal?"],[[0,"type"],[[0,"car"],[1,"x"]],[1,"string"]],[[0,"type"],[1,"key"],[1,"string"]]]]],[2,-1]]],[[0,"otherwise"],[[0,"="],[1,"index"],[2,-1]],[[0,"and"],[[0,"array:set!"],[1,"current"],[1,"index"],[[0,"array:get"],[1,"current"],[2,-1]]],[[0,"array:set!"],[1,"current"],[2,-1]]]],[1,"table"]]]],[[0,"let"],[1,"map:get"],[[0,"lambda"],[1,"table"],[1,"key"],[[0,"do"],[[0,"let"],[1,"idx"],[[0,"set:index"],[1,"table"],[1,"key"]]],[[0,"when"],[[0,"array:in-bounds?"],[1,"table"],[1,"idx"]],[[0,"do"],[[0,"let"],[1,"current"],[[0,"array:get"],[1,"table"],[1,"idx"]]],[[0,"let"],[1,"found"],[[0,"array:find"],[1,"current"],[[0,"lambda"],[1,"x"],[[0,"string:equal?"],[[0,"type"],[1,"key"],[1,"string"]],[[0,"type"],[[0,"array:get"],[1,"x"],[2,0]],[1,"string"]]]]]],[[0,"when"],[[0,"length"],[1,"found"]],[[0,"array:get"],[1,"found"],[2,1]]]]]]]],[[0,"let"],[1,"cast:map->string"],[[0,"lambda"],[1,"table"],[[0,"pi"],[1,"table"],[[0,"array:select"],[1,"length"]],[[0,"array:map"],[[0,"lambda"],[1,"x"],[[0,"array:join"],[[0,"array:map"],[1,"x"],[[0,"lambda"],[1,"y"],[[0,"array:join"],[1,"y"],[2," -> "]]]],[2," "]]]],[[0,"array:join"],[2,"\n"]]]]],[[0,"let"],[1,"map:has?"],[[0,"lambda"],[1,"table"],[1,"key"],[[0,"and"],[[0,"array:in-bounds?"],[1,"table"],[[0,"let"],[1,"idx"],[[0,"set:index"],[1,"table"],[1,"key"]]]],[[0,"and"],[[0,"length"],[[0,"let"],[1,"current"],[[0,"array:get"],[1,"table"],[1,"idx"]]]],[[0,">="],[[0,"array:find-index"],[[0,"car"],[1,"current"]],[[0,"lambda"],[1,"x"],[[0,"string:equal?"],[[0,"type"],[1,"x"],[1,"string"]],[[0,"type"],[1,"key"],[1,"string"]]]]],[2,0]]]]]],[[0,"let"],[1,"list:prev!"],[[0,"safety"],[1,"lambda"],[1,"list"],[1,"node"],[[0,"array:set!"],[1,"list"],[2,0],[[0,"array:set!"],[1,"node"],[2,2],[1,"list"]]]]],[[0,"let"],[1,"list:next!"],[[0,"safety"],[1,"lambda"],[1,"list"],[1,"node"],[[0,"array:set!"],[1,"list"],[2,2],[[0,"array:set!"],[1,"node"],[2,0],[1,"list"]]]]],[[0,"let"],[1,"list:prev"],[[0,"safety"],[1,"lambda"],[1,"list"],[[0,"array:get"],[1,"list"],[2,0]]]],[[0,"let"],[1,"list:next"],[[0,"safety"],[1,"lambda"],[1,"list"],[[0,"array:get"],[1,"list"],[2,2]]]],[[0,"let"],[1,"list:value"],[[0,"lambda"],[1,"node"],[[0,"array:get"],[1,"node"],[2,1]]]],[[0,"let"],[1,"var:def"],[[0,"safety"],[1,"lambda"],[1,"val"],[[0,"array"],[1,"val"]]]],[[0,"let"],[1,"var:get"],[[0,"safety"],[1,"lambda"],[1,"variable"],[[0,"car"],[1,"variable"]]]],[[0,"let"],[1,"var:set!"],[[0,"safety"],[1,"lambda"],[1,"variable"],[1,"value"],[[0,"array:set!"],[1,"variable"],[2,0],[1,"value"]]]],[[0,"let"],[1,"var:del!"],[[0,"safety"],[1,"lambda"],[1,"variable"],[[0,"array:set!"],[1,"variable"],[2,-1]]]],[[0,"let"],[1,"new:brray"],[[0,"lambda"],[[0,"array"],[[0,"array"],[]],[]]]],[[0,"let"],[1,"brray:offset-left"],[[0,"lambda"],[1,"q"],[[0,"*"],[[0,"-"],[[0,"length"],[[0,"array:get"],[1,"q"],[2,0]]],[2,1]],[2,-1]]]],[[0,"let"],[1,"brray:offset-right"],[[0,"lambda"],[1,"q"],[[0,"length"],[[0,"array:get"],[1,"q"],[2,1]]]]],[[0,"let"],[1,"brray:length"],[[0,"lambda"],[1,"q"],[[0,"+"],[[0,"length"],[[0,"array:get"],[1,"q"],[2,0]]],[[0,"length"],[[0,"array:get"],[1,"q"],[2,1]]],[2,-1]]]],[[0,"let"],[1,"brray:empty?"],[[0,"lambda"],[1,"q"],[[0,"not"],[[0,"brray:length"],[1,"q"]]]]],[[0,"let"],[1,"brray:empty!"],[[0,"lambda"],[1,"q"],[[0,"do"],[[0,"array:set!"],[1,"q"],[2,0],[[0,"array"],[]]],[[0,"array:set!"],[1,"q"],[2,1],[]],[1,"q"]]]],[[0,"let"],[1,"brray:get"],[[0,"lambda"],[1,"q"],[1,"offset"],[[0,"do"],[[0,"let"],[1,"offset-index"],[[0,"+"],[1,"offset"],[[0,"brray:offset-left"],[1,"q"]]]],[[0,"let"],[1,"index"],[[0,"if"],[[0,"<"],[1,"offset-index"],[2,0]],[[0,"*"],[1,"offset-index"],[2,-1]],[1,"offset-index"]]],[[0,"if"],[[0,">="],[1,"offset-index"],[2,0]],[[0,"array:get"],[[0,"array:get"],[1,"q"],[2,1]],[1,"index"]],[[0,"array:get"],[[0,"array:get"],[1,"q"],[2,0]],[1,"index"]]]]]],[[0,"let"],[1,"brray:set!"],[[0,"lambda"],[1,"q"],[1,"index"],[1,"value"],[[0,"do"],[[0,"let"],[1,"offset"],[[0,"+"],[1,"offset"],[[0,"brray:offset-left"],[1,"q"]]]],[[0,"if"],[[0,">="],[1,"offset"],[2,0]],[[0,"array:set!"],[[0,"array:get"],[1,"q"],[2,1]],[1,"offset"],[1,"value"]],[[0,"array:set!"],[[0,"array:get"],[1,"q"],[2,0]],[[0,"*"],[1,"offset"],[2,-1]],[1,"value"]]],[1,"q"]]]],[[0,"let"],[1,"brray:add-to-left!"],[[0,"lambda"],[1,"q"],[1,"item"],[[0,"array:set!"],[[0,"let"],[1,"c"],[[0,"array:get"],[1,"q"],[2,0]]],[[0,"length"],[1,"c"]],[1,"item"]]]],[[0,"let"],[1,"brray:add-to-right!"],[[0,"lambda"],[1,"q"],[1,"item"],[[0,"array:set!"],[[0,"let"],[1,"c"],[[0,"array:get"],[1,"q"],[2,1]]],[[0,"length"],[1,"c"]],[1,"item"]]]],[[0,"let"],[1,"brray:remove-from-left!"],[[0,"lambda"],[1,"q"],[[0,"do"],[[0,"let"],[1,"len"],[[0,"brray:length"],[1,"q"]]],[[0,"when"],[1,"len"],[[0,"cond"],[[0,"="],[1,"len"],[2,1]],[[0,"brray:empty!"],[1,"q"]],[[0,">"],[[0,"length"],[[0,"array:get"],[1,"q"],[2,0]]],[2,0]],[[0,"array:set!"],[[0,"array:get"],[1,"q"],[2,0]],[2,-1]]]]]]],[[0,"let"],[1,"brray:remove-from-right!"],[[0,"lambda"],[1,"q"],[[0,"do"],[[0,"let"],[1,"len"],[[0,"brray:length"],[1,"q"]]],[[0,"when"],[1,"len"],[[0,"cond"],[[0,"="],[1,"len"],[2,1]],[[0,"brray:empty!"],[1,"q"]],[[0,">"],[[0,"length"],[[0,"array:get"],[1,"q"],[2,1]]],[2,0]],[[0,"array:set!"],[[0,"array:get"],[1,"q"],[2,1]],[2,-1]]]]]]],[[0,"let"],[1,"brray:iter"],[[0,"lambda"],[1,"q"],[1,"callback"],[[0,"do"],[[0,"let*"],[1,"iter"],[[0,"lambda"],[1,"index"],[1,"bounds"],[[0,"do"],[[0,"callback"],[[0,"brray:get"],[1,"q"],[1,"index"]]],[[0,"when"],[[0,"<"],[1,"index"],[1,"bounds"]],[[0,"iter"],[[0,"+"],[1,"index"],[2,1]],[1,"bounds"]]]]]],[[0,"iter"],[2,0],[[0,"brray:length"],[1,"q"]]]]]],[[0,"let"],[1,"brray:map"],[[0,"lambda"],[1,"q"],[1,"callback"],[[0,"do"],[[0,"let"],[1,"result"],[[0,"new:brray"]]],[[0,"let"],[1,"len"],[[0,"brray:length"],[1,"q"]]],[[0,"let"],[1,"half"],[[0,"math:floor"],[[0,"*"],[1,"len"],[2,0.5]]]],[[0,"let*"],[1,"left"],[[0,"lambda"],[1,"index"],[[0,"do"],[[0,"brray:add-to-left!"],[1,"result"],[[0,"callback"],[[0,"brray:get"],[1,"q"],[1,"index"]]]],[[0,"when"],[[0,">"],[1,"index"],[2,0]],[[0,"left"],[[0,"-"],[1,"index"],[2,1]]]]]]],[[0,"left"],[[0,"-"],[1,"half"],[2,1]]],[[0,"let*"],[1,"rigth"],[[0,"lambda"],[1,"index"],[1,"bounds"],[[0,"do"],[[0,"brray:add-to-right!"],[1,"result"],[[0,"callback"],[[0,"brray:get"],[1,"q"],[1,"index"]]]],[[0,"when"],[[0,"<"],[1,"index"],[1,"bounds"]],[[0,"rigth"],[[0,"+"],[1,"index"],[2,1]],[1,"bounds"]]]]]],[[0,"rigth"],[1,"half"],[[0,"-"],[1,"len"],[2,1]]],[1,"result"]]]],[[0,"let"],[1,"cast:brray->array"],[[0,"lambda"],[1,"q"],[[0,"do"],[[0,"let"],[1,"out"],[]],[[0,"let*"],[1,"iter"],[[0,"lambda"],[1,"index"],[1,"bounds"],[[0,"do"],[[0,"array:set!"],[1,"out"],[[0,"length"],[1,"out"]],[[0,"brray:get"],[1,"q"],[1,"index"]]],[[0,"when"],[[0,"<"],[1,"index"],[1,"bounds"]],[[0,"iter"],[[0,"+"],[1,"index"],[2,1]],[1,"bounds"]]]]]],[[0,"iter"],[2,0],[[0,"-"],[[0,"brray:length"],[1,"q"]],[2,1]]],[1,"out"]]]],[[0,"let"],[1,"brray:balance?"],[[0,"lambda"],[1,"q"],[[0,"="],[[0,"+"],[[0,"brray:offset-right"],[1,"q"]],[[0,"brray:offset-left"],[1,"q"]]],[2,0]]]],[[0,"let"],[1,"brray:balance!"],[[0,"lambda"],[1,"q"],[[0,"if"],[[0,"brray:balance?"],[1,"q"]],[1,"q"],[[0,"do"],[[0,"let"],[1,"initial"],[[0,"cast:brray->array"],[1,"q"]]],[[0,"brray:empty!"],[1,"q"]],[[0,"let"],[1,"half"],[[0,"math:floor"],[[0,"*"],[[0,"length"],[1,"initial"]],[2,0.5]]]],[[0,"let*"],[1,"left"],[[0,"lambda"],[1,"index"],[[0,"do"],[[0,"brray:add-to-left!"],[1,"q"],[[0,"array:get"],[1,"initial"],[1,"index"]]],[[0,"when"],[[0,">"],[1,"index"],[2,0]],[[0,"left"],[[0,"-"],[1,"index"],[2,1]]]]]]],[[0,"left"],[[0,"-"],[1,"half"],[2,1]]],[[0,"let*"],[1,"rigth"],[[0,"lambda"],[1,"index"],[1,"bounds"],[[0,"do"],[[0,"brray:add-to-right!"],[1,"q"],[[0,"array:get"],[1,"initial"],[1,"index"]]],[[0,"when"],[[0,"<"],[1,"index"],[1,"bounds"]],[[0,"rigth"],[[0,"+"],[1,"index"],[2,1]],[1,"bounds"]]]]]],[[0,"rigth"],[1,"half"],[[0,"-"],[[0,"length"],[1,"initial"]],[2,1]]],[1,"q"]]]]],[[0,"let"],[1,"brray:append!"],[[0,"lambda"],[1,"q"],[1,"item"],[[0,"do"],[[0,"brray:add-to-right!"],[1,"q"],[1,"item"]],[1,"q"]]]],[[0,"let"],[1,"brray:prepend!"],[[0,"lambda"],[1,"q"],[1,"item"],[[0,"do"],[[0,"brray:add-to-left!"],[1,"q"],[1,"item"]],[1,"q"]]]],[[0,"let"],[1,"brray:head!"],[[0,"lambda"],[1,"q"],[[0,"do"],[[0,"when"],[[0,"="],[[0,"brray:offset-right"],[1,"q"]],[2,0]],[[0,"brray:balance!"],[1,"q"]]],[[0,"brray:remove-from-right!"],[1,"q"]],[1,"q"]]]],[[0,"let"],[1,"brray:tail!"],[[0,"lambda"],[1,"q"],[[0,"do"],[[0,"when"],[[0,"="],[[0,"brray:offset-left"],[1,"q"]],[2,0]],[[0,"brray:balance!"],[1,"q"]]],[[0,"brray:remove-from-left!"],[1,"q"]],[1,"q"]]]],[[0,"let"],[1,"brray:first"],[[0,"lambda"],[1,"q"],[[0,"brray:get"],[1,"q"],[2,0]]]],[[0,"let"],[1,"brray:last"],[[0,"lambda"],[1,"q"],[[0,"brray:get"],[1,"q"],[[0,"-"],[[0,"brray:length"],[1,"q"]],[2,1]]]]],[[0,"let"],[1,"brray:pop-right!"],[[0,"lambda"],[1,"q"],[[0,"do"],[[0,"let"],[1,"last"],[[0,"brray:last"],[1,"q"]]],[[0,"brray:head!"],[1,"q"]],[1,"last"]]]],[[0,"let"],[1,"brray:pop-left!"],[[0,"lambda"],[1,"q"],[[0,"do"],[[0,"let"],[1,"first"],[[0,"brray:first"],[1,"q"]]],[[0,"brray:tail!"],[1,"q"]],[1,"first"]]]],[[0,"let"],[1,"brray:rotate-left!"],[[0,"lambda"],[1,"q"],[1,"n"],[[0,"do"],[[0,"let"],[1,"N"],[[0,"mod"],[1,"n"],[[0,"brray:length"],[1,"q"]]]],[[0,"let*"],[1,"iter"],[[0,"lambda"],[1,"index"],[1,"bounds"],[[0,"do"],[[0,"when"],[[0,"="],[[0,"brray:offset-left"],[1,"q"]],[2,0]],[[0,"brray:balance!"],[1,"q"]]],[[0,"brray:add-to-right!"],[1,"q"],[[0,"brray:first"],[1,"q"]]],[[0,"brray:remove-from-left!"],[1,"q"]],[[0,"when"],[[0,"<"],[1,"index"],[1,"bounds"]],[[0,"iter"],[[0,"+"],[1,"index"],[2,1]],[1,"bounds"]]]]]],[[0,"iter"],[2,0],[1,"N"]],[1,"q"]]]],[[0,"let"],[1,"brray:rotate-right!"],[[0,"lambda"],[1,"q"],[1,"n"],[[0,"do"],[[0,"let"],[1,"N"],[[0,"mod"],[1,"n"],[[0,"brray:length"],[1,"q"]]]],[[0,"let*"],[1,"iter"],[[0,"lambda"],[1,"index"],[1,"bounds"],[[0,"do"],[[0,"when"],[[0,"="],[[0,"brray:offset-right"],[1,"q"]],[2,0]],[[0,"brray:balance!"],[1,"q"]]],[[0,"brray:add-to-left!"],[1,"q"],[[0,"brray:last"],[1,"q"]]],[[0,"brray:remove-from-right!"],[1,"q"]],[[0,"when"],[[0,"<"],[1,"index"],[1,"bounds"]],[[0,"iter"],[[0,"+"],[1,"index"],[2,1]],[1,"bounds"]]]]]],[[0,"iter"],[2,0],[1,"N"]],[1,"q"]]]],[[0,"let"],[1,"cast:array->brray"],[[0,"lambda"],[1,"initial"],[[0,"do"],[[0,"let"],[1,"q"],[[0,"new:brray"]]],[[0,"let"],[1,"half"],[[0,"math:floor"],[[0,"*"],[[0,"length"],[1,"initial"]],[2,0.5]]]],[[0,"let*"],[1,"left"],[[0,"lambda"],[1,"index"],[[0,"do"],[[0,"brray:add-to-left!"],[1,"q"],[[0,"array:get"],[1,"initial"],[1,"index"]]],[[0,"when"],[[0,">"],[1,"index"],[2,0]],[[0,"left"],[[0,"-"],[1,"index"],[2,1]]]]]]],[[0,"left"],[[0,"-"],[1,"half"],[2,1]]],[[0,"let*"],[1,"rigth"],[[0,"lambda"],[1,"index"],[1,"bounds"],[[0,"do"],[[0,"brray:add-to-right!"],[1,"q"],[[0,"array:get"],[1,"initial"],[1,"index"]]],[[0,"when"],[[0,"<"],[1,"index"],[1,"bounds"]],[[0,"rigth"],[[0,"+"],[1,"index"],[2,1]],[1,"bounds"]]]]]],[[0,"rigth"],[1,"half"],[[0,"-"],[[0,"length"],[1,"initial"]],[2,1]]],[1,"q"]]]],[[0,"let"],[1,"brray:slice"],[[0,"lambda"],[1,"entity"],[1,"s"],[1,"e"],[[0,"do"],[[0,"let"],[1,"len"],[[0,"brray:length"],[1,"entity"]]],[[0,"let"],[1,"start"],[[0,"if"],[[0,"<"],[1,"s"],[2,0]],[[0,"math:max"],[[0,"+"],[1,"len"],[1,"s"]],[2,0]],[[0,"math:min"],[1,"s"],[1,"len"]]]],[[0,"let"],[1,"end"],[[0,"if"],[[0,"<"],[1,"e"],[2,0]],[[0,"math:max"],[[0,"+"],[1,"len"],[1,"e"]],[2,0]],[[0,"math:min"],[1,"e"],[1,"len"]]]],[[0,"let"],[1,"slice"],[[0,"new:brray"]]],[[0,"let"],[1,"slice-len"],[[0,"math:max"],[[0,"-"],[1,"end"],[1,"start"]],[2,0]]],[[0,"let"],[1,"half"],[[0,"math:floor"],[[0,"*"],[1,"slice-len"],[2,0.5]]]],[[0,"let*"],[1,"left"],[[0,"lambda"],[1,"index"],[[0,"do"],[[0,"brray:add-to-left!"],[1,"slice"],[[0,"brray:get"],[1,"entity"],[[0,"+"],[1,"start"],[1,"index"]]]],[[0,"when"],[[0,">"],[1,"index"],[2,0]],[[0,"left"],[[0,"-"],[1,"index"],[2,1]]]]]]],[[0,"left"],[[0,"-"],[1,"half"],[2,1]]],[[0,"let*"],[1,"rigth"],[[0,"lambda"],[1,"index"],[1,"bounds"],[[0,"do"],[[0,"brray:add-to-right!"],[1,"slice"],[[0,"brray:get"],[1,"entity"],[[0,"+"],[1,"start"],[1,"index"]]]],[[0,"when"],[[0,"<"],[1,"index"],[1,"bounds"]],[[0,"rigth"],[[0,"+"],[1,"index"],[2,1]],[1,"bounds"]]]]]],[[0,"rigth"],[1,"half"],[[0,"-"],[1,"slice-len"],[2,1]]],[1,"slice"]]]],[[0,"let"],[1,"date:add-seconds"],[[0,"lambda"],[1,"date-time"],[1,"seconds"],[[0,"+"],[1,"date-time"],[[0,"*"],[1,"seconds"],[2,1000]]]]],[[0,"let"],[1,"date:add-minutes"],[[0,"lambda"],[1,"date-time"],[1,"minutes"],[[0,"+"],[1,"date-time"],[[0,"*"],[1,"minutes"],[2,1000],[2,60]]]]],[[0,"let"],[1,"date:add-hours"],[[0,"lambda"],[1,"date-time"],[1,"hours"],[[0,"+"],[1,"date-time"],[[0,"*"],[1,"hours"],[2,1000],[2,60],[2,60]]]]],[[0,"let"],[1,"date:add-days"],[[0,"lambda"],[1,"date-time"],[1,"days"],[[0,"+"],[1,"date-time"],[[0,"*"],[1,"days"],[2,1000],[2,60],[2,60],[2,24]]]]],[[0,"let"],[1,"date:add-months"],[[0,"lambda"],[1,"date-time"],[1,"months"],[[0,"+"],[1,"date-time"],[[0,"*"],[1,"months"],[2,1000],[2,60],[2,60],[2,24],[2,30]]]]],[[0,"let"],[1,"date:add-years"],[[0,"lambda"],[1,"date-time"],[1,"years"],[[0,"+"],[1,"date-time"],[[0,"*"],[1,"years"],[2,1000],[2,60],[2,60],[2,24],[2,365]]]]],[[0,"let"],[1,"date:sub-seconds"],[[0,"lambda"],[1,"date-time"],[1,"seconds"],[[0,"-"],[1,"date-time"],[[0,"*"],[1,"seconds"],[2,1000]]]]],[[0,"let"],[1,"date:sub-minutes"],[[0,"lambda"],[1,"date-time"],[1,"minutes"],[[0,"-"],[1,"date-time"],[[0,"*"],[1,"minutes"],[2,1000],[2,60]]]]],[[0,"let"],[1,"date:sub-hours"],[[0,"lambda"],[1,"date-time"],[1,"hours"],[[0,"-"],[1,"date-time"],[[0,"*"],[1,"hours"],[2,1000],[2,60],[2,60]]]]],[[0,"let"],[1,"date:sub-days"],[[0,"lambda"],[1,"date-time"],[1,"days"],[[0,"-"],[1,"date-time"],[[0,"*"],[1,"days"],[2,1000],[2,60],[2,60],[2,24]]]]],[[0,"let"],[1,"date:sub-months"],[[0,"lambda"],[1,"date-time"],[1,"months"],[[0,"-"],[1,"date-time"],[[0,"*"],[1,"months"],[2,1000],[2,60],[2,60],[2,24],[2,30]]]]],[[0,"let"],[1,"date:sub-years"],[[0,"lambda"],[1,"date-time"],[1,"years"],[[0,"-"],[1,"date-time"],[[0,"*"],[1,"years"],[2,1000],[2,60],[2,60],[2,24],[2,365]]]]]]
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "fez-lisp",
3
3
  "description": "Lisp interpreted & compiled to JavaScript",
4
4
  "author": "AT290690",
5
- "version": "1.0.29",
5
+ "version": "1.0.31",
6
6
  "type": "module",
7
7
  "main": "index.js",
8
8
  "keywords": [
package/src/enums.js CHANGED
@@ -1,9 +1,10 @@
1
1
  // AST enums
2
2
  export const TYPE = 0
3
3
  export const VALUE = 1
4
- export const WORD = 'w'
5
- export const APPLY = 'f'
6
- export const ATOM = 'a'
4
+
5
+ export const APPLY = 0
6
+ export const WORD = 1
7
+ export const ATOM = 2
7
8
  // tokeniser enums
8
9
  export const PLACEHOLDER = '.'
9
10
  // keywords aliases
@@ -69,13 +70,14 @@ export const KEYWORDS = {
69
70
  TAIL_CALLS_OPTIMISED_RECURSIVE_FUNCTION: 'let*',
70
71
  IMMUTABLE_FUNCTION: 'safety',
71
72
  NOT_COMPILED_BLOCK: 'void',
72
- LOG: 'log!',
73
- CLEAR_CONSOLE: 'clear!',
74
73
 
75
74
  TEST_CASE: 'case',
76
75
  TEST_BED: 'assert',
77
76
  SERIALISE: 'serialise',
78
77
 
78
+ LOG: 'log!',
79
+ CLEAR_CONSOLE: 'clear!',
79
80
  SET_ARRAY: 'array:set!',
81
+
80
82
  DOC: 'fez-manual',
81
83
  }
@@ -4,7 +4,7 @@ import { keywords } from './tokeniser.js'
4
4
  import { stringifyArgs } from './utils.js'
5
5
 
6
6
  export const evaluate = (exp, env) => {
7
- const [first, ...rest] = !isLeaf(exp) ? exp : [exp]
7
+ const [first, ...rest] = isLeaf(exp) ? [exp] : exp
8
8
  if (first == undefined) return []
9
9
  switch (first[TYPE]) {
10
10
  case WORD: {
@@ -32,5 +32,12 @@ export const evaluate = (exp, env) => {
32
32
  )
33
33
  }
34
34
  }
35
+ export const isAtom = (arg, env) => {
36
+ if (arg[TYPE] === ATOM) return 1
37
+ else {
38
+ const atom = evaluate(arg, env)
39
+ return +(typeof atom === 'number' || typeof atom === 'string')
40
+ }
41
+ }
35
42
  export const run = (tree, env = {}) =>
36
43
  keywords[KEYWORDS.BLOCK](tree, { ...keywords, ...env })
package/src/parser.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { APPLY, ATOM, WORD } from './enums.js'
2
2
  import { escape } from './utils.js'
3
3
  export const leaf = (type, value) => [type, value]
4
- export const isLeaf = (tree) => typeof tree[0] === 'string'
4
+ export const isLeaf = ([car]) => car === APPLY || car === ATOM || car === WORD
5
5
  export const parse = (source) => {
6
6
  const tree = []
7
7
  let head = tree,
@@ -0,0 +1,28 @@
1
+ import { APPLY, ATOM, KEYWORDS, TYPE, VALUE, WORD } from '../enums.js'
2
+ import { isLeaf } from '../parser.js'
3
+ import { keywords } from './tokeniser.js'
4
+
5
+ export const evaluate = (exp, env) => {
6
+ const [first, ...rest] = isLeaf(exp) ? [exp] : exp
7
+ if (first == undefined) return []
8
+ switch (first[TYPE]) {
9
+ case WORD:
10
+ return env[first[VALUE]]
11
+ case APPLY:
12
+ const apply = env[first[VALUE]]
13
+ return apply(rest, env)
14
+ case ATOM:
15
+ return first[VALUE]
16
+ default:
17
+ break
18
+ }
19
+ }
20
+ export const isAtom = (arg, env) => {
21
+ if (arg[TYPE] === ATOM) return 1
22
+ else {
23
+ const atom = evaluate(arg, env)
24
+ return +(typeof atom === 'number' || typeof atom === 'string')
25
+ }
26
+ }
27
+ export const run = (tree, env = {}) =>
28
+ keywords[KEYWORDS.BLOCK](tree, { ...keywords, ...env })
@@ -0,0 +1,372 @@
1
+ import std from '../../lib/baked/std.js'
2
+ import { isEqualTypes, stringifyArgs } from '../utils.js'
3
+ import { TYPE, VALUE, WORD, KEYWORDS } from '../enums.js'
4
+ import { evaluate, isAtom } from './interpreter.js'
5
+ import { stringify } from '../parser.js'
6
+ import { isEqual } from '../utils.js'
7
+
8
+ const keywords = {
9
+ [KEYWORDS.CONCATENATION]: (args, env) => {
10
+ const operands = args.map((x) => evaluate(x, env))
11
+ return operands.reduce((a, b) => a + b, '')
12
+ },
13
+ [KEYWORDS.REMAINDER_OF_DIVISION]: (args, env) => {
14
+ const [a, b] = args.map((x) => evaluate(x, env))
15
+ return a % b
16
+ },
17
+ [KEYWORDS.DIVISION]: (args, env) => {
18
+ if (!args.length) return 0
19
+ if (args.length === 1) {
20
+ const number = evaluate(args[0], env)
21
+ return 1 / number
22
+ }
23
+ const operands = args.map((x) => evaluate(x, env))
24
+ return operands.reduce((a, b) => a / b)
25
+ },
26
+ [KEYWORDS.ARRAY_OR_STRING_LENGTH]: (args, env) => {
27
+ const array = evaluate(args[0], env)
28
+ return array.length
29
+ },
30
+ [KEYWORDS.IS_ARRAY]: (args, env) => {
31
+ const array = evaluate(args[0], env)
32
+ return +Array.isArray(array)
33
+ },
34
+ [KEYWORDS.IS_NUMBER]: (args, env) => {
35
+ return +(typeof evaluate(args[0], env) === 'number')
36
+ },
37
+ [KEYWORDS.IS_STRING]: (args, env) => {
38
+ return +(typeof evaluate(args[0], env) === 'string')
39
+ },
40
+ [KEYWORDS.IS_FUNCTION]: (args, env) => {
41
+ return +(typeof evaluate(args[0], env) === 'function')
42
+ },
43
+ [KEYWORDS.ADDITION]: (args, env) => {
44
+ if (!args.length) return 0 // identity
45
+ const operands = args.map((x) => evaluate(x, env))
46
+ return operands.reduce((a, b) => a + b)
47
+ },
48
+ [KEYWORDS.MULTIPLICATION]: (args, env) => {
49
+ if (!args.length) return 1 // identity
50
+ const operands = args.map((x) => evaluate(x, env))
51
+ return operands.reduce((a, b) => a * b)
52
+ },
53
+ [KEYWORDS.SUBTRACTION]: (args, env) => {
54
+ const operands = args.map((x) => evaluate(x, env))
55
+ return args.length === 1 ? -operands[0] : operands.reduce((a, b) => a - b)
56
+ },
57
+ [KEYWORDS.IF]: (args, env) => {
58
+ return evaluate(args[0], env)
59
+ ? evaluate(args[1], env)
60
+ : evaluate(args[2], env)
61
+ },
62
+ [KEYWORDS.UNLESS]: (args, env) => {
63
+ return evaluate(args[0], env)
64
+ ? evaluate(args[2], env)
65
+ : evaluate(args[1], env)
66
+ },
67
+ [KEYWORDS.WHEN]: (args, env) => {
68
+ return evaluate(args[0], env) ? evaluate(args[1], env) : 0
69
+ },
70
+ [KEYWORDS.OTHERWISE]: (args, env) => {
71
+ return evaluate(args[0], env) ? 0 : evaluate(args[1], env)
72
+ },
73
+ [KEYWORDS.CONDITION]: (args, env) => {
74
+ for (let i = 0; i < args.length; i += 2)
75
+ if (evaluate(args[i], env)) return evaluate(args[i + 1], env)
76
+ return 0
77
+ },
78
+ [KEYWORDS.ARRAY_TYPE]: (args, env) => {
79
+ if (!args.length) return []
80
+ const isCapacity =
81
+ args.length === 2 && args[1][TYPE] === WORD && args[1][VALUE] === 'length'
82
+ if (isCapacity) {
83
+ const N = evaluate(args[0], env)
84
+ return new Array(N).fill(0)
85
+ }
86
+ return args.map((x) => evaluate(x, env))
87
+ },
88
+ [KEYWORDS.IS_ATOM]: (args, env) => {
89
+ return isAtom(args[0], env)
90
+ },
91
+ [KEYWORDS.FIRST_ARRAY]: (args, env) => {
92
+ const array = evaluate(args[0], env)
93
+ const value = array.at(0)
94
+ return value
95
+ },
96
+ [KEYWORDS.REST_ARRAY]: (args, env) => {
97
+ const array = evaluate(args[0], env)
98
+ return array.slice(1)
99
+ },
100
+ [KEYWORDS.GET_ARRAY]: (args, env) => {
101
+ const array = evaluate(args[0], env)
102
+ const index = evaluate(args[1], env)
103
+ const value = array.at(index)
104
+ return value
105
+ },
106
+ [KEYWORDS.BLOCK]: (args, env) => {
107
+ return args.reduce((_, x) => evaluate(x, env), 0)
108
+ },
109
+ [KEYWORDS.ANONYMOUS_FUNCTION]: (args, env) => {
110
+ const params = args.slice(0, -1)
111
+ const body = args.at(-1)
112
+ return (props = [], scope) => {
113
+ const localEnv = Object.create(env)
114
+ for (let i = 0; i < props.length; ++i) {
115
+ Object.defineProperty(localEnv, params[i][VALUE], {
116
+ value: evaluate(props[i], scope),
117
+ writable: true,
118
+ })
119
+ }
120
+ return evaluate(body, localEnv)
121
+ }
122
+ },
123
+ [KEYWORDS.NOT]: (args, env) => {
124
+ return +!evaluate(args[0], env)
125
+ },
126
+ [KEYWORDS.EQUAL]: (args, env) => {
127
+ const a = evaluate(args[0], env)
128
+ const b = evaluate(args[1], env)
129
+ return +(a === b)
130
+ },
131
+ [KEYWORDS.LESS_THAN]: (args, env) => {
132
+ const a = evaluate(args[0], env)
133
+ const b = evaluate(args[1], env)
134
+ return +(a < b)
135
+ },
136
+ [KEYWORDS.GREATHER_THAN]: (args, env) => {
137
+ const a = evaluate(args[0], env)
138
+ const b = evaluate(args[1], env)
139
+ return +(a > b)
140
+ },
141
+ [KEYWORDS.GREATHER_THAN_OR_EQUAL]: (args, env) => {
142
+ const a = evaluate(args[0], env)
143
+ const b = evaluate(args[1], env)
144
+ return +(a >= b)
145
+ },
146
+ [KEYWORDS.LESS_THAN_OR_EQUAL]: (args, env) => {
147
+ const a = evaluate(args[0], env)
148
+ const b = evaluate(args[1], env)
149
+ return +(a <= b)
150
+ },
151
+ [KEYWORDS.AND]: (args, env) => {
152
+ let circuit
153
+ for (let i = 0; i < args.length - 1; ++i) {
154
+ circuit = evaluate(args[i], env)
155
+ if (circuit) continue
156
+ else return circuit
157
+ }
158
+ return evaluate(args.at(-1), env)
159
+ },
160
+ [KEYWORDS.OR]: (args, env) => {
161
+ let circuit
162
+ for (let i = 0; i < args.length - 1; ++i) {
163
+ circuit = evaluate(args[i], env)
164
+ if (circuit) return circuit
165
+ else continue
166
+ }
167
+ return evaluate(args.at(-1), env)
168
+ },
169
+ [KEYWORDS.CALL_FUNCTION]: (args, env) => {
170
+ const [first, ...rest] = args
171
+ const apply = evaluate(first, env)
172
+ return apply(rest, env)
173
+ },
174
+ [KEYWORDS.DEFINE_VARIABLE]: (args, env) => {
175
+ let name
176
+ const word = args[0]
177
+ name = word[VALUE]
178
+ Object.defineProperty(env, name, {
179
+ value: evaluate(args[1], env),
180
+ writable: false,
181
+ })
182
+ return env[name]
183
+ },
184
+ [KEYWORDS.STRING_TYPE]: () => '',
185
+ [KEYWORDS.NUMBER_TYPE]: () => 0,
186
+ [KEYWORDS.BOOLEAN_TYPE]: () => 1,
187
+ [KEYWORDS.CAST_TYPE]: (args, env) => {
188
+ const type = args[1][VALUE]
189
+ const value = evaluate(args[0], env)
190
+ if (args.length === 2) {
191
+ switch (type) {
192
+ case KEYWORDS.NUMBER_TYPE: {
193
+ const num = Number(value)
194
+ return num
195
+ }
196
+ case KEYWORDS.STRING_TYPE:
197
+ return value.toString()
198
+ case KEYWORDS.BOOLEAN_TYPE:
199
+ return +!!value
200
+ case KEYWORDS.ARRAY_TYPE: {
201
+ if (typeof value === 'number')
202
+ return [...Number(value).toString()].map(Number)
203
+ return [...value]
204
+ }
205
+ case KEYWORDS.CHAR_TYPE: {
206
+ const index = evaluate(args[0], env)
207
+ return String.fromCharCode(index)
208
+ }
209
+ case KEYWORDS.CHAR_CODE_TYPE: {
210
+ const string = evaluate(args[0], env)
211
+ return string.charCodeAt(0)
212
+ }
213
+ default:
214
+ break
215
+ }
216
+ }
217
+ },
218
+ [KEYWORDS.BITWISE_AND]: (args, env) => {
219
+ const operands = args.map((a) => evaluate(a, env))
220
+ return operands.reduce((acc, x) => acc & x)
221
+ },
222
+ [KEYWORDS.BITWISE_NOT]: (args, env) => {
223
+ const operand = evaluate(args[0], env)
224
+ return ~operand
225
+ },
226
+ [KEYWORDS.BITWISE_OR]: (args, env) => {
227
+ const operands = args.map((a) => evaluate(a, env))
228
+ return operands.reduce((acc, x) => acc | x)
229
+ },
230
+ [KEYWORDS.BITWISE_XOR]: (args, env) => {
231
+ const operands = args.map((a) => evaluate(a, env))
232
+ return operands.reduce((acc, x) => acc ^ x)
233
+ },
234
+ [KEYWORDS.BITWISE_LEFT_SHIFT]: (args, env) => {
235
+ const operands = args.map((a) => evaluate(a, env))
236
+ return operands.reduce((acc, x) => acc << x)
237
+ },
238
+ [KEYWORDS.BITWISE_RIGHT_SHIFT]: (args, env) => {
239
+ const operands = args.map((a) => evaluate(a, env))
240
+ return operands.reduce((acc, x) => acc >> x)
241
+ },
242
+ [KEYWORDS.BITWISE_UNSIGNED_RIGHT_SHIFT]: (args, env) => {
243
+ const operands = args.map((a) => evaluate(a, env))
244
+ return operands.reduce((acc, x) => acc >>> x)
245
+ },
246
+ [KEYWORDS.PIPE]: (args, env) => {
247
+ let inp = args[0]
248
+ for (let i = 1; i < args.length; ++i) {
249
+ const [first, ...rest] = args[i]
250
+ const arr = [first, inp, ...rest]
251
+ inp = arr
252
+ }
253
+ return evaluate(inp, env)
254
+ },
255
+ [KEYWORDS.THROW_ERROR]: (args, env) => {
256
+ const string = evaluate(args[0], env)
257
+ throw new Error(string)
258
+ },
259
+ [KEYWORDS.MERGE]: (args, env) => {
260
+ const arrays = args.map((arg) => evaluate(arg, env))
261
+ return arrays.reduce((a, b) => a.concat(b), [])
262
+ },
263
+ [KEYWORDS.IMMUTABLE_FUNCTION]: (args, env) => {
264
+ const [, ...functionArgs] = args
265
+ const params = functionArgs.slice(0, -1)
266
+ const body = functionArgs.at(-1)
267
+ return (props = [], scope) => {
268
+ const localEnv = Object.create({ ...keywords })
269
+ for (let i = 0; i < props.length; ++i) {
270
+ Object.defineProperty(localEnv, params[i][VALUE], {
271
+ value: evaluate(props[i], scope),
272
+ writable: true,
273
+ })
274
+ }
275
+ return evaluate(body, localEnv)
276
+ }
277
+ },
278
+ [KEYWORDS.TAIL_CALLS_OPTIMISED_RECURSIVE_FUNCTION]: (args, env) => {
279
+ return keywords[KEYWORDS.DEFINE_VARIABLE](args, env)
280
+ },
281
+ [KEYWORDS.TEST_CASE]: (args, env) => {
282
+ const description = evaluate(args[0], env)
283
+ const a = evaluate(args[1], env)
284
+ const b = evaluate(args[2], env)
285
+ return !isEqualTypes(a, b) || !isEqual(a, b)
286
+ ? [0, description, stringifyArgs([args[1]]), b, a]
287
+ : [1, description, stringifyArgs([args[1]]), a]
288
+ },
289
+ [KEYWORDS.TEST_BED]: (args, env) => {
290
+ let tests = []
291
+ try {
292
+ tests = args.map((x) => evaluate(x, env))
293
+ tests.forEach(([state, describe, ...rest]) =>
294
+ !state
295
+ ? console.log(
296
+ '\x1b[31m',
297
+ `${describe} Failed:\n`,
298
+
299
+ `${rest[0]} => ${stringify(rest[1])} != ${stringify(rest[2])}`,
300
+ '\n',
301
+ '\x1b[0m'
302
+ )
303
+ : console.log(
304
+ '\x1b[32m',
305
+ `${describe} Passed:\n`,
306
+ `${rest[0]} => ${stringify(rest[1])}`,
307
+ '\n',
308
+ '\x1b[0m'
309
+ )
310
+ )
311
+ } catch (err) {
312
+ console.log('\x1b[31m', 'Tests failed: \n', err.toString())
313
+ }
314
+ const result = !tests.length || tests.some(([t]) => !t)
315
+ result
316
+ ? console.log('\x1b[31m', 'Some tests failed!', '\n', '\x1b[0m')
317
+ : console.log('\x1b[32m', 'All tests passed!', '\n', '\x1b[0m')
318
+ return +!result
319
+ },
320
+ [KEYWORDS.SERIALISE]: (args, env) => {
321
+ const data = evaluate(args[0], env)
322
+ return stringify(data)
323
+ },
324
+ [KEYWORDS.SET_ARRAY]: (args, env) => {
325
+ const array = evaluate(args[0], env)
326
+ const index = evaluate(args[1], env)
327
+ if (index < 0) {
328
+ const target = array.length + index
329
+ while (array.length !== target) array.pop()
330
+ } else {
331
+ const value = evaluate(args[2], env)
332
+ array[index] = value
333
+ }
334
+ return array
335
+ },
336
+ [KEYWORDS.LOG]: (args, env) => {
337
+ const expressions = args.map((x) => evaluate(x, env))
338
+ console.log(...expressions)
339
+ return expressions.at(-1)
340
+ },
341
+ [KEYWORDS.CLEAR_CONSOLE]: (args) => {
342
+ console.clear()
343
+ return 0
344
+ },
345
+ }
346
+ keywords[KEYWORDS.NOT_COMPILED_BLOCK] = keywords[KEYWORDS.BLOCK]
347
+ keywords[KEYWORDS.DOC] = (args, env) => {
348
+ const lib = evaluate(args[0], env)
349
+ const kw = Object.keys(env).map((x) => [x])
350
+ const standard = std.map(([_, [_0, name], [_1, ...arg]]) => {
351
+ const args = arg
352
+ .slice(0, -1)
353
+ .map((x) => x[VALUE])
354
+ .filter((x) => x !== 'lambda')
355
+ return [name, ...args]
356
+ })
357
+ const all = [...kw, ...standard]
358
+ switch (lib) {
359
+ case '*':
360
+ return all.map((x) => `(${x.join(' ')})`)
361
+ case 'keywords':
362
+ return kw.map((x) => `(${x.join(' ')})`)
363
+ case 'std':
364
+ return standard.map((x) => `(${x.join(' ')})`)
365
+ default:
366
+ return all
367
+ .filter((name) => name[0].includes(lib))
368
+ .map((x) => `(${x.join(' ')})`)
369
+ }
370
+ }
371
+
372
+ export { keywords }
package/src/tokeniser.js CHANGED
@@ -1,9 +1,8 @@
1
1
  import std from '../lib/baked/std.js'
2
2
  import { TYPE, VALUE, WORD, KEYWORDS, APPLY } from './enums.js'
3
- import { evaluate } from './interpreter.js'
3
+ import { evaluate, isAtom } from './interpreter.js'
4
4
  import { stringify } from './parser.js'
5
5
  import {
6
- isAtom,
7
6
  isEqual,
8
7
  isEqualTypes,
9
8
  isForbiddenVariableName,
@@ -251,9 +250,8 @@ const keywords = {
251
250
  KEYWORDS.CONDITION
252
251
  } ${stringifyArgs(args)})`
253
252
  )
254
- for (let i = 0; i < args.length; i += 2) {
253
+ for (let i = 0; i < args.length; i += 2)
255
254
  if (evaluate(args[i], env)) return evaluate(args[i + 1], env)
256
- }
257
255
  return 0
258
256
  },
259
257
  [KEYWORDS.ARRAY_TYPE]: (args, env) => {
package/src/utils.js CHANGED
@@ -9,7 +9,8 @@ import {
9
9
  VALUE,
10
10
  WORD,
11
11
  } from './enums.js'
12
- import { evaluate, run } from './interpreter.js'
12
+ import { run } from './interpreter.js'
13
+ import { run as runPlain } from './plain/interpreter.js'
13
14
  import { isLeaf, parse } from './parser.js'
14
15
  export const logError = (error) => console.log('\x1b[31m', error, '\x1b[0m')
15
16
  export const logSuccess = (output) => console.log(output, '\x1b[0m')
@@ -75,13 +76,6 @@ export const isForbiddenVariableName = (name) => {
75
76
  return false
76
77
  }
77
78
  }
78
- export const isAtom = (arg, env) => {
79
- if (arg[TYPE] === ATOM) return 1
80
- else {
81
- const atom = evaluate(arg, env)
82
- return +(typeof atom === 'number' || typeof atom === 'string')
83
- }
84
- }
85
79
  export const isEqual = (a, b) =>
86
80
  +(
87
81
  (Array.isArray(a) &&
@@ -171,6 +165,12 @@ export const runFromInterpreted = (source, env = {}) => {
171
165
  )
172
166
  run(tree, env)
173
167
  }
168
+ export const runFromInterpretedPlain = (source, env = {}) => {
169
+ const tree = parse(
170
+ handleUnbalancedQuotes(handleUnbalancedParens(removeNoCode(source)))
171
+ )
172
+ runPlain(tree, env)
173
+ }
174
174
  export const dfs = (tree, callback) => {
175
175
  if (!isLeaf(tree)) for (const leaf of tree) dfs(leaf)
176
176
  else callback(tree)
@@ -202,7 +202,7 @@ export const fez = (source, options = {}) => {
202
202
  const js = Object.values(comp(deepClone(ast))).join('')
203
203
  return options.eval ? eval(js) : js
204
204
  }
205
- return run(ast, env)
205
+ return options.errors ? run(ast, env) : runPlain(ast, env)
206
206
  } catch (error) {
207
207
  const err = error.message
208
208
  .replace("'[object Array]'", '(array)')
@@ -277,6 +277,8 @@ export const decompress = (raw) => {
277
277
  for (const tok of runes) result += tok
278
278
  return result
279
279
  }
280
+ // shake(parse(removeNoCode(source)), std)
281
+ export const shake = (parsed, std) => [...treeShake(parsed, std), ...parsed]
280
282
  export const lispToJavaScriptVariableName = (name) =>
281
283
  toCamelCase(
282
284
  arrowToTo(