fez-lisp 1.0.0 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
package/README.md CHANGED
@@ -25,15 +25,15 @@
25
25
  675
26
26
  1456")
27
27
  ; solve part 1
28
- (let solve (lambda array cb
29
- (fold array (lambda a b (do
30
- (let res (binary-search array (cb b)))
28
+ (let solve (lambda arr cb
29
+ (fold arr (lambda a b (do
30
+ (let res (binary-search arr (cb b)))
31
31
  (if res (merge a (Array res)) a)))
32
32
  ())))
33
33
  ; 514579
34
34
  (go *input*
35
35
  (split "\n")
36
- (strings->numbers)
36
+ (Strings->Numbers)
37
37
  (sort (lambda a b (> a b)))
38
38
  (solve (lambda x (- 2020 x)))
39
39
  (product)
@@ -54,9 +54,9 @@
54
54
  ```
55
55
 
56
56
  ```lisp
57
- ; remove duplicate elements in the array
58
- (let unique (lambda array (go
59
- (let sorted (sort array (safety lambda a b (> a b))))
57
+ ; remove duplicate elements in the arr
58
+ (let unique (lambda arr (go
59
+ (let sorted (sort arr (safety lambda a b (> a b))))
60
60
  (zip (sequence sorted))
61
61
  (select (lambda x
62
62
  (or (not (let index (car (cdr x))))
@@ -71,19 +71,24 @@
71
71
  <p align="center">
72
72
  <img width="64" src="./js.svg"/>
73
73
  </p>
74
+ Installation:
75
+
76
+ ```
77
+ npm i fez-lisp
78
+ ```
74
79
 
75
80
  ```js
76
- import { fez } from '../index.js'
81
+ import { fez } from 'fez-lisp'
77
82
  fez(`(log! "Hello World!")`)
78
83
  ```
79
84
 
80
85
  ```js
81
- import { fez } from '../index.js'
86
+ import { fez } from 'fez-lisp'
82
87
  fez(`(+ 1 "2")`, { errors: true })
83
88
  ```
84
89
 
85
90
  ```js
86
- import { fez } from '../index.js'
91
+ import { fez } from 'fez-lisp'
87
92
  eval(
88
93
  fez(
89
94
  `(go
@@ -97,9 +102,11 @@ eval(
97
102
  )
98
103
  )
99
104
  ```
105
+
100
106
  ```js
101
- import { fez } from '../index.js'
102
- fez(`(let fizz-buzz (lambda n
107
+ import { fez } from 'fez-lisp'
108
+ fez(
109
+ `(let fizz-buzz (lambda n
103
110
  (cond
104
111
  (= (mod n 15) 0) "Fizz Buzz"
105
112
  (= (mod n 3) 0) "Fizz"
@@ -107,5 +114,6 @@ fez(`(let fizz-buzz (lambda n
107
114
  (*) n)))
108
115
 
109
116
  (go (range 1 100) (scan fizz-buzz) (log!))`,
110
- { std: true, errors: true, compile: false, shake: true })
117
+ { std: true, errors: true, compile: false, shake: true }
118
+ )
111
119
  ```
package/cli/index.js CHANGED
@@ -95,7 +95,7 @@ export default async () => {
95
95
  )
96
96
  const result = run([...treeShake(parsed, STD), ...parsed], env)
97
97
  if (typeof result === 'function') {
98
- console.log(inpColor, `(λ)`)
98
+ console.log(inpColor, `λ`)
99
99
  } else if (Array.isArray(result)) {
100
100
  console.log(
101
101
  outColor,
package/index.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import { evaluate } from './src/interpreter.js'
2
- import { parse } from './src/parser.js'
2
+ import { parse, stringify } from './src/parser.js'
3
3
  import { fez } from './src/utils.js'
4
4
  import std from './lib/baked/std.js'
5
5
  import { keywords } from './src/tokeniser.js'
6
6
  import { WORD, APPLY, ATOM, VALUE, TYPE } from './src/enums.js'
7
7
  const types = { WORD, APPLY, ATOM, VALUE, TYPE }
8
- export { fez, parse, keywords, evaluate, std, types }
8
+ export { fez, parse, stringify, keywords, evaluate, std, types }
package/lib/baked/std.js CHANGED
@@ -1 +1 @@
1
- export default [[{"t":"f","v":"let"},{"t":"w","v":"E"},{"t":"a","v":2.718281828459045}],[{"t":"f","v":"let"},{"t":"w","v":"PI"},{"t":"a","v":3.141592653589793}],[{"t":"f","v":"let*"},{"t":"w","v":"iteration"},[{"t":"f","v":"lambda"},{"t":"w","v":"array"},{"t":"w","v":"callback"},[{"t":"f","v":"when"},[{"t":"f","v":"length"},{"t":"w","v":"array"}],[{"t":"f","v":"do"},[{"t":"f","v":"callback"},[{"t":"f","v":"car"},{"t":"w","v":"array"}]],[{"t":"f","v":"iteration"},[{"t":"f","v":"cdr"},{"t":"w","v":"array"}],{"t":"w","v":"callback"}]]]]],[{"t":"f","v":"let"},{"t":"w","v":"scan"},[{"t":"f","v":"lambda"},{"t":"w","v":"array"},{"t":"w","v":"callback"},[{"t":"f","v":"do"},[{"t":"f","v":"let*"},{"t":"w","v":"iterate"},[{"t":"f","v":"lambda"},{"t":"w","v":"array"},{"t":"w","v":"out"},[{"t":"f","v":"if"},[{"t":"f","v":"length"},{"t":"w","v":"array"}],[{"t":"f","v":"iterate"},[{"t":"f","v":"cdr"},{"t":"w","v":"array"}],[{"t":"f","v":"merge"},{"t":"w","v":"out"},[{"t":"f","v":"Array"},[{"t":"f","v":"callback"},[{"t":"f","v":"car"},{"t":"w","v":"array"}]]]]],{"t":"w","v":"out"}]]],[{"t":"f","v":"iterate"},{"t":"w","v":"array"},[]]]]],[{"t":"f","v":"let"},{"t":"w","v":"select"},[{"t":"f","v":"lambda"},{"t":"w","v":"array"},{"t":"w","v":"callback"},[{"t":"f","v":"do"},[{"t":"f","v":"let*"},{"t":"w","v":"iterate"},[{"t":"f","v":"lambda"},{"t":"w","v":"array"},{"t":"w","v":"out"},[{"t":"f","v":"if"},[{"t":"f","v":"length"},{"t":"w","v":"array"}],[{"t":"f","v":"iterate"},[{"t":"f","v":"cdr"},{"t":"w","v":"array"}],[{"t":"f","v":"if"},[{"t":"f","v":"callback"},[{"t":"f","v":"car"},{"t":"w","v":"array"}]],[{"t":"f","v":"merge"},{"t":"w","v":"out"},[{"t":"f","v":"Array"},[{"t":"f","v":"car"},{"t":"w","v":"array"}]]],{"t":"w","v":"out"}]],{"t":"w","v":"out"}]]],[{"t":"f","v":"iterate"},{"t":"w","v":"array"},[]]]]],[{"t":"f","v":"let"},{"t":"w","v":"exclude"},[{"t":"f","v":"lambda"},{"t":"w","v":"array"},{"t":"w","v":"callback"},[{"t":"f","v":"do"},[{"t":"f","v":"let*"},{"t":"w","v":"iterate"},[{"t":"f","v":"lambda"},{"t":"w","v":"array"},{"t":"w","v":"out"},[{"t":"f","v":"if"},[{"t":"f","v":"length"},{"t":"w","v":"array"}],[{"t":"f","v":"iterate"},[{"t":"f","v":"cdr"},{"t":"w","v":"array"}],[{"t":"f","v":"if"},[{"t":"f","v":"not"},[{"t":"f","v":"callback"},[{"t":"f","v":"car"},{"t":"w","v":"array"}]]],[{"t":"f","v":"merge"},{"t":"w","v":"out"},[{"t":"f","v":"Array"},[{"t":"f","v":"car"},{"t":"w","v":"array"}]]],{"t":"w","v":"out"}]],{"t":"w","v":"out"}]]],[{"t":"f","v":"iterate"},{"t":"w","v":"array"},[]]]]],[{"t":"f","v":"let"},{"t":"w","v":"fold"},[{"t":"f","v":"lambda"},{"t":"w","v":"array"},{"t":"w","v":"callback"},{"t":"w","v":"initial"},[{"t":"f","v":"do"},[{"t":"f","v":"let*"},{"t":"w","v":"iterate"},[{"t":"f","v":"lambda"},{"t":"w","v":"array"},{"t":"w","v":"out"},[{"t":"f","v":"if"},[{"t":"f","v":"length"},{"t":"w","v":"array"}],[{"t":"f","v":"iterate"},[{"t":"f","v":"cdr"},{"t":"w","v":"array"}],[{"t":"f","v":"callback"},{"t":"w","v":"out"},[{"t":"f","v":"car"},{"t":"w","v":"array"}]]],{"t":"w","v":"out"}]]],[{"t":"f","v":"iterate"},{"t":"w","v":"array"},{"t":"w","v":"initial"}]]]],[{"t":"f","v":"let"},{"t":"w","v":"every?"},[{"t":"f","v":"lambda"},{"t":"w","v":"array"},{"t":"w","v":"callback"},[{"t":"f","v":"do"},[{"t":"f","v":"let*"},{"t":"w","v":"iterate"},[{"t":"f","v":"lambda"},{"t":"w","v":"array"},[{"t":"f","v":"if"},[{"t":"f","v":"and"},[{"t":"f","v":"length"},{"t":"w","v":"array"}],[{"t":"f","v":"callback"},[{"t":"f","v":"car"},{"t":"w","v":"array"}]]],[{"t":"f","v":"iterate"},[{"t":"f","v":"cdr"},{"t":"w","v":"array"}]],[{"t":"f","v":"not"},[{"t":"f","v":"length"},{"t":"w","v":"array"}]]]]],[{"t":"f","v":"iterate"},{"t":"w","v":"array"}]]]],[{"t":"f","v":"let"},{"t":"w","v":"some?"},[{"t":"f","v":"lambda"},{"t":"w","v":"array"},{"t":"w","v":"callback"},[{"t":"f","v":"do"},[{"t":"f","v":"let*"},{"t":"w","v":"iterate"},[{"t":"f","v":"lambda"},{"t":"w","v":"array"},[{"t":"f","v":"if"},[{"t":"f","v":"and"},[{"t":"f","v":"length"},{"t":"w","v":"array"}],[{"t":"f","v":"not"},[{"t":"f","v":"callback"},[{"t":"f","v":"car"},{"t":"w","v":"array"}]]]],[{"t":"f","v":"iterate"},[{"t":"f","v":"cdr"},{"t":"w","v":"array"}]],[{"t":"f","v":"type"},[{"t":"f","v":"length"},{"t":"w","v":"array"}],{"t":"w","v":"Boolean"}]]]],[{"t":"f","v":"iterate"},{"t":"w","v":"array"}]]]],[{"t":"f","v":"let"},{"t":"w","v":"find"},[{"t":"f","v":"lambda"},{"t":"w","v":"array"},{"t":"w","v":"callback"},[{"t":"f","v":"do"},[{"t":"f","v":"let*"},{"t":"w","v":"iterate"},[{"t":"f","v":"lambda"},{"t":"w","v":"array"},[{"t":"f","v":"when"},[{"t":"f","v":"length"},{"t":"w","v":"array"}],[{"t":"f","v":"if"},[{"t":"f","v":"callback"},[{"t":"f","v":"car"},{"t":"w","v":"array"}]],[{"t":"f","v":"car"},{"t":"w","v":"array"}],[{"t":"f","v":"iterate"},[{"t":"f","v":"cdr"},{"t":"w","v":"array"}]]]]]],[{"t":"f","v":"iterate"},{"t":"w","v":"array"}]]]],[{"t":"f","v":"let"},{"t":"w","v":"has?"},[{"t":"f","v":"lambda"},{"t":"w","v":"array"},{"t":"w","v":"callback"},[{"t":"f","v":"do"},[{"t":"f","v":"let*"},{"t":"w","v":"iterate"},[{"t":"f","v":"lambda"},{"t":"w","v":"array"},[{"t":"f","v":"when"},[{"t":"f","v":"length"},{"t":"w","v":"array"}],[{"t":"f","v":"if"},[{"t":"f","v":"callback"},[{"t":"f","v":"car"},{"t":"w","v":"array"}]],{"t":"a","v":1},[{"t":"f","v":"iterate"},[{"t":"f","v":"cdr"},{"t":"w","v":"array"}]]]]]],[{"t":"f","v":"iterate"},{"t":"w","v":"array"}]]]],[{"t":"f","v":"let"},{"t":"w","v":"reverse"},[{"t":"f","v":"lambda"},{"t":"w","v":"array"},[{"t":"f","v":"do"},[{"t":"f","v":"let*"},{"t":"w","v":"iterate"},[{"t":"f","v":"lambda"},{"t":"w","v":"array"},{"t":"w","v":"out"},[{"t":"f","v":"if"},[{"t":"f","v":"length"},{"t":"w","v":"array"}],[{"t":"f","v":"iterate"},[{"t":"f","v":"cdr"},{"t":"w","v":"array"}],[{"t":"f","v":"merge"},[{"t":"f","v":"Array"},[{"t":"f","v":"car"},{"t":"w","v":"array"}]],{"t":"w","v":"out"}]],{"t":"w","v":"out"}]]],[{"t":"f","v":"iterate"},{"t":"w","v":"array"},[]]]]],[{"t":"f","v":"let"},{"t":"w","v":"range"},[{"t":"f","v":"lambda"},{"t":"w","v":"start"},{"t":"w","v":"end"},[{"t":"f","v":"do"},[{"t":"f","v":"let*"},{"t":"w","v":"iterate"},[{"t":"f","v":"lambda"},{"t":"w","v":"out"},{"t":"w","v":"count"},[{"t":"f","v":"if"},[{"t":"f","v":"<="},{"t":"w","v":"count"},{"t":"w","v":"end"}],[{"t":"f","v":"iterate"},[{"t":"f","v":"merge"},{"t":"w","v":"out"},[{"t":"f","v":"Array"},{"t":"w","v":"count"}]],[{"t":"f","v":"+"},{"t":"w","v":"count"},{"t":"a","v":1}]],{"t":"w","v":"out"}]]],[{"t":"f","v":"iterate"},[],{"t":"w","v":"start"}]]]],[{"t":"f","v":"let"},{"t":"w","v":"sequence"},[{"t":"f","v":"lambda"},{"t":"w","v":"array"},[{"t":"f","v":"do"},[{"t":"f","v":"let"},{"t":"w","v":"end"},[{"t":"f","v":"length"},{"t":"w","v":"array"}]],[{"t":"f","v":"let*"},{"t":"w","v":"iterate"},[{"t":"f","v":"lambda"},{"t":"w","v":"out"},{"t":"w","v":"count"},[{"t":"f","v":"if"},[{"t":"f","v":"<"},[{"t":"f","v":"length"},{"t":"w","v":"out"}],{"t":"w","v":"end"}],[{"t":"f","v":"iterate"},[{"t":"f","v":"merge"},{"t":"w","v":"out"},[{"t":"f","v":"Array"},{"t":"w","v":"count"}]],[{"t":"f","v":"+"},{"t":"w","v":"count"},{"t":"a","v":1}]],{"t":"w","v":"out"}]]],[{"t":"f","v":"iterate"},[],{"t":"a","v":0}]]]],[{"t":"f","v":"let"},{"t":"w","v":"sequence-n"},[{"t":"f","v":"lambda"},{"t":"w","v":"n"},[{"t":"f","v":"do"},[{"t":"f","v":"let*"},{"t":"w","v":"iterate"},[{"t":"f","v":"lambda"},{"t":"w","v":"out"},{"t":"w","v":"count"},[{"t":"f","v":"if"},[{"t":"f","v":"<"},[{"t":"f","v":"length"},{"t":"w","v":"out"}],{"t":"w","v":"n"}],[{"t":"f","v":"iterate"},[{"t":"f","v":"merge"},{"t":"w","v":"out"},[{"t":"f","v":"Array"},{"t":"w","v":"count"}]],[{"t":"f","v":"+"},{"t":"w","v":"count"},{"t":"a","v":1}]],{"t":"w","v":"out"}]]],[{"t":"f","v":"iterate"},[],{"t":"a","v":0}]]]],[{"t":"f","v":"let"},{"t":"w","v":"unique"},[{"t":"f","v":"lambda"},{"t":"w","v":"array"},[{"t":"f","v":"go"},[{"t":"f","v":"let"},{"t":"w","v":"sorted"},[{"t":"f","v":"sort"},{"t":"w","v":"array"},[{"t":"f","v":"safety"},{"t":"w","v":"lambda"},{"t":"w","v":"a"},{"t":"w","v":"b"},[{"t":"f","v":">"},{"t":"w","v":"a"},{"t":"w","v":"b"}]]]],[{"t":"f","v":"zip"},[{"t":"f","v":"sequence"},{"t":"w","v":"sorted"}]],[{"t":"f","v":"select"},[{"t":"f","v":"lambda"},{"t":"w","v":"x"},[{"t":"f","v":"or"},[{"t":"f","v":"not"},[{"t":"f","v":"let"},{"t":"w","v":"index"},[{"t":"f","v":"car"},[{"t":"f","v":"cdr"},{"t":"w","v":"x"}]]]],[{"t":"f","v":"not"},[{"t":"f","v":"="},[{"t":"f","v":"get"},{"t":"w","v":"sorted"},[{"t":"f","v":"-"},{"t":"w","v":"index"},{"t":"a","v":1}]],[{"t":"f","v":"get"},{"t":"w","v":"sorted"},{"t":"w","v":"index"}]]]]]],[{"t":"f","v":"scan"},{"t":"w","v":"car"}]]]],[{"t":"f","v":"let"},{"t":"w","v":"for-range"},[{"t":"f","v":"lambda"},{"t":"w","v":"start"},{"t":"w","v":"end"},{"t":"w","v":"callback"},[{"t":"f","v":"do"},[{"t":"f","v":"let*"},{"t":"w","v":"iterate"},[{"t":"f","v":"lambda"},{"t":"w","v":"i"},[{"t":"f","v":"when"},[{"t":"f","v":"<"},{"t":"w","v":"i"},{"t":"w","v":"end"}],[{"t":"f","v":"do"},[{"t":"f","v":"callback"},{"t":"w","v":"i"}],[{"t":"f","v":"iterate"},[{"t":"f","v":"+"},{"t":"w","v":"i"},{"t":"a","v":1}]]]]]],[{"t":"f","v":"iterate"},{"t":"w","v":"start"}]]]],[{"t":"f","v":"let"},{"t":"w","v":"list-range"},[{"t":"f","v":"lambda"},{"t":"w","v":"start"},{"t":"w","v":"end"},[{"t":"f","v":"do"},[{"t":"f","v":"let"},{"t":"w","v":"range"},[{"t":"f","v":"lambda"},{"t":"w","v":"list"},{"t":"w","v":"start"},{"t":"w","v":"end"},[{"t":"f","v":"if"},[{"t":"f","v":"<"},{"t":"w","v":"start"},{"t":"w","v":"end"}],[{"t":"f","v":"Array"},[{"t":"f","v":"merge"},{"t":"w","v":"list"},[{"t":"f","v":"range"},[{"t":"f","v":"Array"},[{"t":"f","v":"Array"},[{"t":"f","v":"+"},{"t":"w","v":"start"},{"t":"a","v":1}]]],[{"t":"f","v":"+"},{"t":"w","v":"start"},{"t":"a","v":1}],{"t":"w","v":"end"}]]],{"t":"w","v":"list"}]]],[{"t":"f","v":"car"},[{"t":"f","v":"car"},[{"t":"f","v":"range"},[],{"t":"w","v":"start"},{"t":"w","v":"end"}]]]]]],[{"t":"f","v":"let"},{"t":"w","v":"traverse"},[{"t":"f","v":"lambda"},{"t":"w","v":"x"},{"t":"w","v":"callback"},[{"t":"f","v":"if"},[{"t":"f","v":"Atom?"},{"t":"w","v":"x"}],[{"t":"f","v":"callback"},{"t":"w","v":"x"}],[{"t":"f","v":"iterate"},{"t":"w","v":"x"},[{"t":"f","v":"lambda"},{"t":"w","v":"y"},[{"t":"f","v":"traverse"},{"t":"w","v":"y"},{"t":"w","v":"callback"}]]]]]],[{"t":"f","v":"let"},{"t":"w","v":"summation"},[{"t":"f","v":"lambda"},{"t":"w","v":"array"},[{"t":"f","v":"fold"},{"t":"w","v":"array"},[{"t":"f","v":"safety"},{"t":"w","v":"lambda"},{"t":"w","v":"a"},{"t":"w","v":"b"},[{"t":"f","v":"+"},{"t":"w","v":"a"},{"t":"w","v":"b"}]],{"t":"a","v":0}]]],[{"t":"f","v":"let"},{"t":"w","v":"product"},[{"t":"f","v":"lambda"},{"t":"w","v":"array"},[{"t":"f","v":"fold"},{"t":"w","v":"array"},[{"t":"f","v":"safety"},{"t":"w","v":"lambda"},{"t":"w","v":"a"},{"t":"w","v":"b"},[{"t":"f","v":"*"},{"t":"w","v":"a"},{"t":"w","v":"b"}]],{"t":"a","v":1}]]],[{"t":"f","v":"let"},{"t":"w","v":"maximum"},[{"t":"f","v":"lambda"},{"t":"w","v":"array"},[{"t":"f","v":"fold"},{"t":"w","v":"array"},[{"t":"f","v":"safety"},{"t":"w","v":"lambda"},{"t":"w","v":"a"},{"t":"w","v":"b"},[{"t":"f","v":"if"},[{"t":"f","v":">"},{"t":"w","v":"a"},{"t":"w","v":"b"}],{"t":"w","v":"a"},{"t":"w","v":"b"}]],[{"t":"f","v":"car"},{"t":"w","v":"array"}]]]],[{"t":"f","v":"let"},{"t":"w","v":"minimum"},[{"t":"f","v":"lambda"},{"t":"w","v":"array"},[{"t":"f","v":"fold"},{"t":"w","v":"array"},[{"t":"f","v":"safety"},{"t":"w","v":"lambda"},{"t":"w","v":"a"},{"t":"w","v":"b"},[{"t":"f","v":"if"},[{"t":"f","v":"<"},{"t":"w","v":"a"},{"t":"w","v":"b"}],{"t":"w","v":"a"},{"t":"w","v":"b"}]],[{"t":"f","v":"car"},{"t":"w","v":"array"}]]]],[{"t":"f","v":"let"},{"t":"w","v":"max"},[{"t":"f","v":"lambda"},{"t":"w","v":"a"},{"t":"w","v":"b"},[{"t":"f","v":"if"},[{"t":"f","v":">"},{"t":"w","v":"a"},{"t":"w","v":"b"}],{"t":"w","v":"a"},{"t":"w","v":"b"}]]],[{"t":"f","v":"let"},{"t":"w","v":"min"},[{"t":"f","v":"lambda"},{"t":"w","v":"a"},{"t":"w","v":"b"},[{"t":"f","v":"if"},[{"t":"f","v":"<"},{"t":"w","v":"a"},{"t":"w","v":"b"}],{"t":"w","v":"a"},{"t":"w","v":"b"}]]],[{"t":"f","v":"let"},{"t":"w","v":"count-of"},[{"t":"f","v":"lambda"},{"t":"w","v":"array"},{"t":"w","v":"callback"},[{"t":"f","v":"go"},{"t":"w","v":"array"},[{"t":"f","v":"select"},{"t":"w","v":"callback"}],[{"t":"f","v":"length"}]]]],[{"t":"f","v":"let"},{"t":"w","v":"increment"},[{"t":"f","v":"safety"},{"t":"w","v":"lambda"},{"t":"w","v":"i"},[{"t":"f","v":"+"},{"t":"w","v":"i"},{"t":"a","v":1}]]],[{"t":"f","v":"let"},{"t":"w","v":"floor"},[{"t":"f","v":"safety"},{"t":"w","v":"lambda"},{"t":"w","v":"n"},[{"t":"f","v":"|"},{"t":"w","v":"n"},{"t":"a","v":0}]]],[{"t":"f","v":"let"},{"t":"w","v":"round"},[{"t":"f","v":"safety"},{"t":"w","v":"lambda"},{"t":"w","v":"n"},[{"t":"f","v":"|"},[{"t":"f","v":"+"},{"t":"w","v":"n"},{"t":"a","v":0.5}],{"t":"a","v":0}]]],[{"t":"f","v":"let"},{"t":"w","v":"empty?"},[{"t":"f","v":"safety"},{"t":"w","v":"lambda"},{"t":"w","v":"array"},[{"t":"f","v":"not"},[{"t":"f","v":"length"},{"t":"w","v":"array"}]]]],[{"t":"f","v":"let"},{"t":"w","v":"array-in-bounds?"},[{"t":"f","v":"safety"},{"t":"w","v":"lambda"},{"t":"w","v":"array"},{"t":"w","v":"index"},[{"t":"f","v":"and"},[{"t":"f","v":"<"},{"t":"w","v":"index"},[{"t":"f","v":"length"},{"t":"w","v":"array"}]],[{"t":"f","v":">="},{"t":"w","v":"index"},{"t":"a","v":0}]]]],[{"t":"f","v":"let"},{"t":"w","v":"string->array"},[{"t":"f","v":"safety"},{"t":"w","v":"lambda"},{"t":"w","v":"string"},[{"t":"f","v":"type"},{"t":"w","v":"string"},{"t":"w","v":"Array"}]]],[{"t":"f","v":"let"},{"t":"w","v":"array->string"},[{"t":"f","v":"lambda"},{"t":"w","v":"array"},[{"t":"f","v":"fold"},{"t":"w","v":"array"},[{"t":"f","v":"safety"},{"t":"w","v":"lambda"},{"t":"w","v":"a"},{"t":"w","v":"x"},[{"t":"f","v":"concatenate"},{"t":"w","v":"a"},[{"t":"f","v":"type"},{"t":"w","v":"x"},{"t":"w","v":"String"}]]],{"t":"a","v":""}]]],[{"t":"f","v":"let"},{"t":"w","v":"string->number"},[{"t":"f","v":"safety"},{"t":"w","v":"lambda"},{"t":"w","v":"string"},[{"t":"f","v":"type"},{"t":"w","v":"string"},{"t":"w","v":"Number"}]]],[{"t":"f","v":"let"},{"t":"w","v":"number->string"},[{"t":"f","v":"safety"},{"t":"w","v":"lambda"},{"t":"w","v":"number"},[{"t":"f","v":"type"},{"t":"w","v":"number"},{"t":"w","v":"String"}]]],[{"t":"f","v":"let"},{"t":"w","v":"strings->numbers"},[{"t":"f","v":"lambda"},{"t":"w","v":"array"},[{"t":"f","v":"scan"},{"t":"w","v":"array"},[{"t":"f","v":"safety"},{"t":"w","v":"lambda"},{"t":"w","v":"x"},[{"t":"f","v":"type"},{"t":"w","v":"x"},{"t":"w","v":"Number"}]]]]],[{"t":"f","v":"let"},{"t":"w","v":"numbers->strings"},[{"t":"f","v":"lambda"},{"t":"w","v":"array"},[{"t":"f","v":"scan"},{"t":"w","v":"array"},[{"t":"f","v":"safety"},{"t":"w","v":"lambda"},{"t":"w","v":"x"},[{"t":"f","v":"type"},{"t":"w","v":"x"},{"t":"w","v":"String"}]]]]],[{"t":"f","v":"let"},{"t":"w","v":"string->charcodes"},[{"t":"f","v":"lambda"},{"t":"w","v":"string"},[{"t":"f","v":"go"},{"t":"w","v":"string"},[{"t":"f","v":"type"},{"t":"w","v":"Array"}],[{"t":"f","v":"scan"},[{"t":"f","v":"lambda"},{"t":"w","v":"x"},[{"t":"f","v":"type"},{"t":"w","v":"x"},{"t":"w","v":"Char-Code"}]]]]]],[{"t":"f","v":"let"},{"t":"w","v":"chars->charcodes"},[{"t":"f","v":"lambda"},{"t":"w","v":"array"},[{"t":"f","v":"go"},{"t":"w","v":"array"},[{"t":"f","v":"scan"},[{"t":"f","v":"lambda"},{"t":"w","v":"x"},[{"t":"f","v":"type"},{"t":"w","v":"x"},{"t":"w","v":"Char-Code"}]]]]]],[{"t":"f","v":"let"},{"t":"w","v":"charcodes->chars"},[{"t":"f","v":"lambda"},{"t":"w","v":"array"},[{"t":"f","v":"go"},{"t":"w","v":"array"},[{"t":"f","v":"scan"},[{"t":"f","v":"lambda"},{"t":"w","v":"x"},[{"t":"f","v":"type"},{"t":"w","v":"x"},{"t":"w","v":"Char"}]]]]]],[{"t":"f","v":"let"},{"t":"w","v":"charcodes->string"},[{"t":"f","v":"lambda"},{"t":"w","v":"array"},[{"t":"f","v":"go"},{"t":"w","v":"array"},[{"t":"f","v":"scan"},[{"t":"f","v":"lambda"},{"t":"w","v":"x"},[{"t":"f","v":"type"},{"t":"w","v":"x"},{"t":"w","v":"Char"}]]],[{"t":"f","v":"array->string"}]]]],[{"t":"f","v":"let"},{"t":"w","v":"power"},[{"t":"f","v":"lambda"},{"t":"w","v":"base"},{"t":"w","v":"exp"},[{"t":"f","v":"if"},[{"t":"f","v":"<"},{"t":"w","v":"exp"},{"t":"a","v":0}],[{"t":"f","v":"if"},[{"t":"f","v":"="},{"t":"w","v":"base"},{"t":"a","v":0}],[{"t":"f","v":"throw"},{"t":"a","v":"Attempting to divide by 0 in (power)"}],[{"t":"f","v":"/"},[{"t":"f","v":"*"},{"t":"w","v":"base"},[{"t":"f","v":"power"},{"t":"w","v":"base"},[{"t":"f","v":"-"},[{"t":"f","v":"*"},{"t":"w","v":"exp"},{"t":"a","v":-1}],{"t":"a","v":1}]]]]],[{"t":"f","v":"cond"},[{"t":"f","v":"="},{"t":"w","v":"exp"},{"t":"a","v":0}],{"t":"a","v":1},[{"t":"f","v":"="},{"t":"w","v":"exp"},{"t":"a","v":1}],{"t":"w","v":"base"},[{"t":"f","v":"*"}],[{"t":"f","v":"*"},{"t":"w","v":"base"},[{"t":"f","v":"power"},{"t":"w","v":"base"},[{"t":"f","v":"-"},{"t":"w","v":"exp"},{"t":"a","v":1}]]]]]]],[{"t":"f","v":"let"},{"t":"w","v":"greatest-common-divisor"},[{"t":"f","v":"lambda"},{"t":"w","v":"a"},{"t":"w","v":"b"},[{"t":"f","v":"do"},[{"t":"f","v":"let*"},{"t":"w","v":"gcd"},[{"t":"f","v":"lambda"},{"t":"w","v":"a"},{"t":"w","v":"b"},[{"t":"f","v":"if"},[{"t":"f","v":"="},{"t":"w","v":"b"},{"t":"a","v":0}],{"t":"w","v":"a"},[{"t":"f","v":"gcd"},{"t":"w","v":"b"},[{"t":"f","v":"mod"},{"t":"w","v":"a"},{"t":"w","v":"b"}]]]],[{"t":"f","v":"gcd"},{"t":"w","v":"a"},{"t":"w","v":"b"}]]]]],[{"t":"f","v":"let"},{"t":"w","v":"least-common-divisor"},[{"t":"f","v":"lambda"},{"t":"w","v":"a"},{"t":"w","v":"b"},[{"t":"f","v":"*"},{"t":"w","v":"a"},{"t":"w","v":"b"},[{"t":"f","v":"/"},[{"t":"f","v":"greatest-common-divisor"},{"t":"w","v":"a"},{"t":"w","v":"b"}]]]]],[{"t":"f","v":"let"},{"t":"w","v":"sqrt"},[{"t":"f","v":"lambda"},{"t":"w","v":"x"},[{"t":"f","v":"do"},[{"t":"f","v":"let"},{"t":"w","v":"is-good-enough"},[{"t":"f","v":"lambda"},{"t":"w","v":"g"},{"t":"w","v":"x"},[{"t":"f","v":"<"},[{"t":"f","v":"abs"},[{"t":"f","v":"-"},[{"t":"f","v":"square"},{"t":"w","v":"g"}],{"t":"w","v":"x"}]],{"t":"a","v":0.01}]],{"t":"w","v":"improve-guess"},[{"t":"f","v":"lambda"},{"t":"w","v":"g"},{"t":"w","v":"x"},[{"t":"f","v":"average"},{"t":"w","v":"g"},[{"t":"f","v":"*"},{"t":"w","v":"x"},[{"t":"f","v":"/"},{"t":"w","v":"g"}]]]]],[{"t":"f","v":"let*"},{"t":"w","v":"sqrt-iter"},[{"t":"f","v":"lambda"},{"t":"w","v":"g"},{"t":"w","v":"x"},[{"t":"f","v":"if"},[{"t":"f","v":"is-good-enough"},{"t":"w","v":"g"},{"t":"w","v":"x"}],{"t":"w","v":"g"},[{"t":"f","v":"sqrt-iter"},[{"t":"f","v":"improve-guess"},{"t":"w","v":"g"},{"t":"w","v":"x"}],{"t":"w","v":"x"}]]]],[{"t":"f","v":"sqrt-iter"},{"t":"a","v":1},{"t":"w","v":"x"}]]]],[{"t":"f","v":"let"},{"t":"w","v":"circumference"},[{"t":"f","v":"lambda"},{"t":"w","v":"radius"},[{"t":"f","v":"*"},{"t":"w","v":"PI"},[{"t":"f","v":"*"},{"t":"w","v":"radius"},{"t":"a","v":2}]]]],[{"t":"f","v":"let"},{"t":"w","v":"hypotenuse"},[{"t":"f","v":"lambda"},{"t":"w","v":"a"},{"t":"w","v":"b"},[{"t":"f","v":"sqrt"},[{"t":"f","v":"+"},[{"t":"f","v":"*"},{"t":"w","v":"a"},{"t":"w","v":"a"}],[{"t":"f","v":"*"},{"t":"w","v":"b"},{"t":"w","v":"b"}]]]]],[{"t":"f","v":"let"},{"t":"w","v":"abs"},[{"t":"f","v":"safety"},{"t":"w","v":"lambda"},{"t":"w","v":"n"},[{"t":"f","v":"-"},[{"t":"f","v":"^"},{"t":"w","v":"n"},[{"t":"f","v":">>"},{"t":"w","v":"n"},{"t":"a","v":31}]],[{"t":"f","v":">>"},{"t":"w","v":"n"},{"t":"a","v":31}]]]],[{"t":"f","v":"let"},{"t":"w","v":"nth-digit"},[{"t":"f","v":"lambda"},{"t":"w","v":"digit"},{"t":"w","v":"n"},[{"t":"f","v":"|"},[{"t":"f","v":"mod"},[{"t":"f","v":"/"},{"t":"w","v":"digit"},[{"t":"f","v":"power"},{"t":"a","v":10},[{"t":"f","v":"-"},{"t":"w","v":"n"},{"t":"a","v":1}]]],{"t":"a","v":10}],{"t":"a","v":0.5}]]],[{"t":"f","v":"let"},{"t":"w","v":"normalize"},[{"t":"f","v":"safety"},{"t":"w","v":"lambda"},{"t":"w","v":"value"},{"t":"w","v":"min"},{"t":"w","v":"max"},[{"t":"f","v":"*"},[{"t":"f","v":"-"},{"t":"w","v":"value"},{"t":"w","v":"min"}],[{"t":"f","v":"/"},[{"t":"f","v":"-"},{"t":"w","v":"max"},{"t":"w","v":"min"}]]]]],[{"t":"f","v":"let"},{"t":"w","v":"linear-interpolation"},[{"t":"f","v":"safety"},{"t":"w","v":"lambda"},{"t":"w","v":"a"},{"t":"w","v":"b"},{"t":"w","v":"n"},[{"t":"f","v":"+"},[{"t":"f","v":"*"},[{"t":"f","v":"-"},{"t":"a","v":1},{"t":"w","v":"n"}],{"t":"w","v":"a"}],[{"t":"f","v":"*"},{"t":"w","v":"n"},{"t":"w","v":"b"}]]]],[{"t":"f","v":"let"},{"t":"w","v":"gauss-sum"},[{"t":"f","v":"safety"},{"t":"w","v":"lambda"},{"t":"w","v":"n"},[{"t":"f","v":"*"},{"t":"w","v":"n"},[{"t":"f","v":"+"},{"t":"w","v":"n"},{"t":"a","v":1}],{"t":"a","v":0.5}]]],[{"t":"f","v":"let"},{"t":"w","v":"gauss-sum-sequance"},[{"t":"f","v":"safety"},{"t":"w","v":"lambda"},{"t":"w","v":"a"},{"t":"w","v":"b"},[{"t":"f","v":"*"},[{"t":"f","v":"+"},{"t":"w","v":"a"},{"t":"w","v":"b"}],[{"t":"f","v":"+"},[{"t":"f","v":"-"},{"t":"w","v":"b"},{"t":"w","v":"a"}],{"t":"a","v":1}],{"t":"a","v":0.5}]]],[{"t":"f","v":"let"},{"t":"w","v":"clamp"},[{"t":"f","v":"safety"},{"t":"w","v":"lambda"},{"t":"w","v":"x"},{"t":"w","v":"limit"},[{"t":"f","v":"if"},[{"t":"f","v":">"},{"t":"w","v":"x"},{"t":"w","v":"limit"}],{"t":"w","v":"limit"},{"t":"w","v":"x"}]]],[{"t":"f","v":"let"},{"t":"w","v":"odd?"},[{"t":"f","v":"safety"},{"t":"w","v":"lambda"},{"t":"w","v":"x"},[{"t":"f","v":"="},[{"t":"f","v":"mod"},{"t":"w","v":"x"},{"t":"a","v":2}],{"t":"a","v":1}]]],[{"t":"f","v":"let"},{"t":"w","v":"even?"},[{"t":"f","v":"safety"},{"t":"w","v":"lambda"},{"t":"w","v":"x"},[{"t":"f","v":"="},[{"t":"f","v":"mod"},{"t":"w","v":"x"},{"t":"a","v":2}],{"t":"a","v":0}]]],[{"t":"f","v":"let"},{"t":"w","v":"sign"},[{"t":"f","v":"safety"},{"t":"w","v":"lambda"},{"t":"w","v":"n"},[{"t":"f","v":"if"},[{"t":"f","v":"<"},{"t":"w","v":"n"},{"t":"a","v":0}],{"t":"a","v":-1},{"t":"a","v":1}]]],[{"t":"f","v":"let"},{"t":"w","v":"radians"},[{"t":"f","v":"lambda"},{"t":"w","v":"deg"},[{"t":"f","v":"*"},{"t":"w","v":"deg"},{"t":"w","v":"PI"},[{"t":"f","v":"/"},{"t":"a","v":180}]]]],[{"t":"f","v":"let"},{"t":"w","v":"average"},[{"t":"f","v":"safety"},{"t":"w","v":"lambda"},{"t":"w","v":"x"},{"t":"w","v":"y"},[{"t":"f","v":"*"},[{"t":"f","v":"+"},{"t":"w","v":"x"},{"t":"w","v":"y"}],{"t":"a","v":0.5}]]],[{"t":"f","v":"let"},{"t":"w","v":"euclidean-mod"},[{"t":"f","v":"safety"},{"t":"w","v":"lambda"},{"t":"w","v":"a"},{"t":"w","v":"b"},[{"t":"f","v":"mod"},[{"t":"f","v":"+"},[{"t":"f","v":"mod"},{"t":"w","v":"a"},{"t":"w","v":"b"}],{"t":"w","v":"b"}],{"t":"w","v":"b"}]]],[{"t":"f","v":"let"},{"t":"w","v":"euclidean-distance"},[{"t":"f","v":"lambda"},{"t":"w","v":"x1"},{"t":"w","v":"y1"},{"t":"w","v":"x2"},{"t":"w","v":"y2"},[{"t":"f","v":"do"},[{"t":"f","v":"let"},{"t":"w","v":"a"},[{"t":"f","v":"-"},{"t":"w","v":"x1"},{"t":"w","v":"x2"}]],[{"t":"f","v":"let"},{"t":"w","v":"b"},[{"t":"f","v":"-"},{"t":"w","v":"y1"},{"t":"w","v":"y2"}]],[{"t":"f","v":"sqrt"},[{"t":"f","v":"+"},[{"t":"f","v":"*"},{"t":"w","v":"a"},{"t":"w","v":"a"}],[{"t":"f","v":"*"},{"t":"w","v":"b"},{"t":"w","v":"b"}]]]]]],[{"t":"f","v":"let"},{"t":"w","v":"manhattan-distance"},[{"t":"f","v":"lambda"},{"t":"w","v":"x1"},{"t":"w","v":"y1"},{"t":"w","v":"x2"},{"t":"w","v":"y2"},[{"t":"f","v":"+"},[{"t":"f","v":"abs"},[{"t":"f","v":"-"},{"t":"w","v":"x2"},{"t":"w","v":"x1"}]],[{"t":"f","v":"abs"},[{"t":"f","v":"-"},{"t":"w","v":"y2"},{"t":"w","v":"y1"}]]]]],[{"t":"f","v":"let"},{"t":"w","v":"positive?"},[{"t":"f","v":"safety"},{"t":"w","v":"lambda"},{"t":"w","v":"num"},[{"t":"f","v":">"},{"t":"w","v":"num"},{"t":"a","v":0}]]],[{"t":"f","v":"let"},{"t":"w","v":"negative?"},[{"t":"f","v":"safety"},{"t":"w","v":"lambda"},{"t":"w","v":"num"},[{"t":"f","v":"<"},{"t":"w","v":"num"},{"t":"a","v":0}]]],[{"t":"f","v":"let"},{"t":"w","v":"zero?"},[{"t":"f","v":"safety"},{"t":"w","v":"lambda"},{"t":"w","v":"num"},[{"t":"f","v":"="},{"t":"w","v":"num"},{"t":"a","v":0}]]],[{"t":"f","v":"let"},{"t":"w","v":"divisible?"},[{"t":"f","v":"safety"},{"t":"w","v":"lambda"},{"t":"w","v":"a"},{"t":"w","v":"b"},[{"t":"f","v":"="},[{"t":"f","v":"mod"},{"t":"w","v":"a"},{"t":"w","v":"b"}],{"t":"a","v":0}]]],[{"t":"f","v":"let"},{"t":"w","v":"prime?"},[{"t":"f","v":"lambda"},{"t":"w","v":"n"},[{"t":"f","v":"cond"},[{"t":"f","v":"="},{"t":"w","v":"n"},{"t":"a","v":1}],{"t":"a","v":0},[{"t":"f","v":"<"},{"t":"w","v":"n"},{"t":"a","v":0}],{"t":"a","v":0},[{"t":"f","v":"*"}],[{"t":"f","v":"do"},[{"t":"f","v":"let*"},{"t":"w","v":"iter"},[{"t":"f","v":"lambda"},{"t":"w","v":"i"},{"t":"w","v":"end"},[{"t":"f","v":"do"},[{"t":"f","v":"let"},{"t":"w","v":"it-is"},[{"t":"f","v":"not"},[{"t":"f","v":"="},[{"t":"f","v":"mod"},{"t":"w","v":"n"},{"t":"w","v":"i"}],{"t":"a","v":0}]]],[{"t":"f","v":"if"},[{"t":"f","v":"and"},[{"t":"f","v":"<="},{"t":"w","v":"i"},{"t":"w","v":"end"}],{"t":"w","v":"it-is"}],[{"t":"f","v":"iter"},[{"t":"f","v":"+"},{"t":"w","v":"i"},{"t":"a","v":1}],{"t":"w","v":"end"}],{"t":"w","v":"it-is"}]]]],[{"t":"f","v":"or"},[{"t":"f","v":"="},{"t":"w","v":"n"},{"t":"a","v":2}],[{"t":"f","v":"iter"},{"t":"a","v":2},[{"t":"f","v":"sqrt"},{"t":"w","v":"n"}]]]]]]],[{"t":"f","v":"let"},{"t":"w","v":"slice"},[{"t":"f","v":"safety"},{"t":"w","v":"lambda"},{"t":"w","v":"array"},{"t":"w","v":"start"},{"t":"w","v":"end"},[{"t":"f","v":"do"},[{"t":"f","v":"let"},{"t":"w","v":"bounds"},[{"t":"f","v":"-"},{"t":"w","v":"end"},{"t":"w","v":"start"}]],[{"t":"f","v":"let*"},{"t":"w","v":"iterate"},[{"t":"f","v":"lambda"},{"t":"w","v":"i"},{"t":"w","v":"out"},[{"t":"f","v":"if"},[{"t":"f","v":"<"},{"t":"w","v":"i"},{"t":"w","v":"bounds"}],[{"t":"f","v":"iterate"},[{"t":"f","v":"+"},{"t":"w","v":"i"},{"t":"a","v":1}],[{"t":"f","v":"merge"},{"t":"w","v":"out"},[{"t":"f","v":"Array"},[{"t":"f","v":"get"},{"t":"w","v":"array"},[{"t":"f","v":"+"},{"t":"w","v":"start"},{"t":"w","v":"i"}]]]]],{"t":"w","v":"out"}]]],[{"t":"f","v":"iterate"},{"t":"a","v":0},[]]]]],[{"t":"f","v":"let"},{"t":"w","v":"binary-search"},[{"t":"f","v":"lambda"},{"t":"w","v":"array"},{"t":"w","v":"target"},[{"t":"f","v":"do"},[{"t":"f","v":"let*"},{"t":"w","v":"search"},[{"t":"f","v":"lambda"},{"t":"w","v":"arr"},{"t":"w","v":"target"},{"t":"w","v":"start"},{"t":"w","v":"end"},[{"t":"f","v":"do"},[{"t":"f","v":"when"},[{"t":"f","v":"<="},{"t":"w","v":"start"},{"t":"w","v":"end"}],[{"t":"f","v":"do"},[{"t":"f","v":"let"},{"t":"w","v":"index"},[{"t":"f","v":"floor"},[{"t":"f","v":"*"},[{"t":"f","v":"+"},{"t":"w","v":"start"},{"t":"w","v":"end"}],{"t":"a","v":0.5}]]],[{"t":"f","v":"let"},{"t":"w","v":"current"},[{"t":"f","v":"get"},{"t":"w","v":"arr"},{"t":"w","v":"index"}]],[{"t":"f","v":"if"},[{"t":"f","v":"="},{"t":"w","v":"target"},{"t":"w","v":"current"}],{"t":"w","v":"target"},[{"t":"f","v":"if"},[{"t":"f","v":">"},{"t":"w","v":"current"},{"t":"w","v":"target"}],[{"t":"f","v":"search"},{"t":"w","v":"arr"},{"t":"w","v":"target"},{"t":"w","v":"start"},[{"t":"f","v":"-"},{"t":"w","v":"index"},{"t":"a","v":1}]],[{"t":"f","v":"search"},{"t":"w","v":"arr"},{"t":"w","v":"target"},[{"t":"f","v":"+"},{"t":"w","v":"index"},{"t":"a","v":1}],{"t":"w","v":"end"}]]]]]]]],[{"t":"f","v":"search"},{"t":"w","v":"array"},{"t":"w","v":"target"},{"t":"a","v":0},[{"t":"f","v":"length"},{"t":"w","v":"array"}]]]]],[{"t":"f","v":"let"},{"t":"w","v":"zip"},[{"t":"f","v":"safety"},{"t":"w","v":"lambda"},{"t":"w","v":"A"},{"t":"w","v":"B"},[{"t":"f","v":"do"},[{"t":"f","v":"let*"},{"t":"w","v":"iterate"},[{"t":"f","v":"lambda"},{"t":"w","v":"a"},{"t":"w","v":"b"},{"t":"w","v":"output"},[{"t":"f","v":"if"},[{"t":"f","v":"and"},[{"t":"f","v":"length"},{"t":"w","v":"a"}],[{"t":"f","v":"length"},{"t":"w","v":"b"}]],[{"t":"f","v":"iterate"},[{"t":"f","v":"cdr"},{"t":"w","v":"a"}],[{"t":"f","v":"cdr"},{"t":"w","v":"b"}],[{"t":"f","v":"merge"},{"t":"w","v":"output"},[{"t":"f","v":"Array"},[{"t":"f","v":"Array"},[{"t":"f","v":"car"},{"t":"w","v":"a"}],[{"t":"f","v":"car"},{"t":"w","v":"b"}]]]]],{"t":"w","v":"output"}]]],[{"t":"f","v":"iterate"},{"t":"w","v":"A"},{"t":"w","v":"B"},[]]]]],[{"t":"f","v":"let"},{"t":"w","v":"cartesian-product"},[{"t":"f","v":"lambda"},{"t":"w","v":"a"},{"t":"w","v":"b"},[{"t":"f","v":"fold"},{"t":"w","v":"a"},[{"t":"f","v":"lambda"},{"t":"w","v":"p"},{"t":"w","v":"x"},[{"t":"f","v":"merge"},{"t":"w","v":"p"},[{"t":"f","v":"scan"},{"t":"w","v":"b"},[{"t":"f","v":"lambda"},{"t":"w","v":"y"},[{"t":"f","v":"Array"},{"t":"w","v":"x"},{"t":"w","v":"y"}]]]]],[]]]],[{"t":"f","v":"let"},{"t":"w","v":"equal?"},[{"t":"f","v":"lambda"},{"t":"w","v":"a"},{"t":"w","v":"b"},[{"t":"f","v":"or"},[{"t":"f","v":"and"},[{"t":"f","v":"Atom?"},{"t":"w","v":"a"}],[{"t":"f","v":"Atom?"},{"t":"w","v":"b"}],[{"t":"f","v":"="},{"t":"w","v":"a"},{"t":"w","v":"b"}]],[{"t":"f","v":"and"},[{"t":"f","v":"Array?"},{"t":"w","v":"a"}],[{"t":"f","v":"="},[{"t":"f","v":"length"},{"t":"w","v":"a"}],[{"t":"f","v":"length"},{"t":"w","v":"b"}]],[{"t":"f","v":"not"},[{"t":"f","v":"some?"},[{"t":"f","v":"sequence"},{"t":"w","v":"a"}],[{"t":"f","v":"lambda"},{"t":"w","v":"i"},[{"t":"f","v":"not"},[{"t":"f","v":"equal?"},[{"t":"f","v":"get"},{"t":"w","v":"a"},{"t":"w","v":"i"}],[{"t":"f","v":"get"},{"t":"w","v":"b"},{"t":"w","v":"i"}]]]]]]]]]],[{"t":"f","v":"let"},{"t":"w","v":"split"},[{"t":"f","v":"lambda"},{"t":"w","v":"string"},{"t":"w","v":"delim"},[{"t":"f","v":"do"},[{"t":"f","v":"let"},{"t":"w","v":"input"},[{"t":"f","v":"type"},[{"t":"f","v":"concatenate"},{"t":"w","v":"string"},{"t":"w","v":"delim"}],{"t":"w","v":"Array"}]],[{"t":"f","v":"let"},{"t":"w","v":"marks"},[{"t":"f","v":"go"},{"t":"w","v":"input"},[{"t":"f","v":"zip"},[{"t":"f","v":"sequence"},{"t":"w","v":"input"}]],[{"t":"f","v":"scan"},[{"t":"f","v":"lambda"},{"t":"w","v":"x"},[{"t":"f","v":"if"},[{"t":"f","v":"="},[{"t":"f","v":"car"},{"t":"w","v":"x"}],{"t":"w","v":"delim"}],[{"t":"f","v":"car"},[{"t":"f","v":"cdr"},{"t":"w","v":"x"}]],[{"t":"f","v":"car"},{"t":"w","v":"x"}]]]]]],[{"t":"f","v":"let"},{"t":"w","v":"first"},[{"t":"f","v":"find"},{"t":"w","v":"marks"},[{"t":"f","v":"lambda"},{"t":"w","v":"x"},[{"t":"f","v":"Number?"},{"t":"w","v":"x"}]]]],[{"t":"f","v":"go"},{"t":"w","v":"marks"},[{"t":"f","v":"fold"},[{"t":"f","v":"lambda"},{"t":"w","v":"a"},{"t":"w","v":"b"},[{"t":"f","v":"if"},[{"t":"f","v":"Number?"},{"t":"w","v":"b"}],[{"t":"f","v":"merge"},{"t":"w","v":"a"},[{"t":"f","v":"Array"},[{"t":"f","v":"slice"},{"t":"w","v":"input"},[{"t":"f","v":"-"},{"t":"w","v":"b"},{"t":"w","v":"first"}],{"t":"w","v":"b"}]]],{"t":"w","v":"a"}]],[]],[{"t":"f","v":"scan"},[{"t":"f","v":"lambda"},{"t":"w","v":"x"},[{"t":"f","v":"array->string"},{"t":"w","v":"x"}]]]]]]],[{"t":"f","v":"let"},{"t":"w","v":"join"},[{"t":"f","v":"lambda"},{"t":"w","v":"array"},{"t":"w","v":"delim"},[{"t":"f","v":"fold"},[{"t":"f","v":"zip"},{"t":"w","v":"array"},[{"t":"f","v":"sequence"},{"t":"w","v":"array"}]],[{"t":"f","v":"lambda"},{"t":"w","v":"a"},{"t":"w","v":"b"},[{"t":"f","v":"if"},[{"t":"f","v":">"},[{"t":"f","v":"car"},[{"t":"f","v":"cdr"},{"t":"w","v":"b"}]],{"t":"a","v":0}],[{"t":"f","v":"concatenate"},{"t":"w","v":"a"},{"t":"w","v":"delim"},[{"t":"f","v":"type"},[{"t":"f","v":"car"},{"t":"w","v":"b"}],{"t":"w","v":"String"}]],[{"t":"f","v":"type"},[{"t":"f","v":"car"},{"t":"w","v":"b"}],{"t":"w","v":"String"}]]],{"t":"a","v":""}]]],[{"t":"f","v":"let"},{"t":"w","v":"flat"},[{"t":"f","v":"lambda"},{"t":"w","v":"array"},[{"t":"f","v":"do"},[{"t":"f","v":"let"},{"t":"w","v":"flatten"},[{"t":"f","v":"lambda"},{"t":"w","v":"item"},[{"t":"f","v":"if"},[{"t":"f","v":"and"},[{"t":"f","v":"Array?"},{"t":"w","v":"item"}],[{"t":"f","v":"length"},{"t":"w","v":"item"}]],[{"t":"f","v":"fold"},{"t":"w","v":"item"},[{"t":"f","v":"lambda"},{"t":"w","v":"a"},{"t":"w","v":"b"},[{"t":"f","v":"merge"},{"t":"w","v":"a"},[{"t":"f","v":"flatten"},{"t":"w","v":"b"}]]],[]],[{"t":"f","v":"Array"},{"t":"w","v":"item"}]]]],[{"t":"f","v":"flatten"},{"t":"w","v":"array"}]]]],[{"t":"f","v":"let"},{"t":"w","v":"sort"},[{"t":"f","v":"lambda"},{"t":"w","v":"arr"},{"t":"w","v":"callback"},[{"t":"f","v":"do"},[{"t":"f","v":"if"},[{"t":"f","v":"<="},[{"t":"f","v":"length"},{"t":"w","v":"arr"}],{"t":"a","v":1}],{"t":"w","v":"arr"},[{"t":"f","v":"do"},[{"t":"f","v":"let"},{"t":"w","v":"pivot"},[{"t":"f","v":"car"},{"t":"w","v":"arr"}]],[{"t":"f","v":"let*"},{"t":"w","v":"iterate"},[{"t":"f","v":"lambda"},{"t":"w","v":"i"},{"t":"w","v":"bounds"},{"t":"w","v":"a"},{"t":"w","v":"b"},[{"t":"f","v":"do"},[{"t":"f","v":"let"},{"t":"w","v":"current"},[{"t":"f","v":"get"},{"t":"w","v":"arr"},{"t":"w","v":"i"}]],[{"t":"f","v":"let"},{"t":"w","v":"predicate"},[{"t":"f","v":"callback"},{"t":"w","v":"current"},{"t":"w","v":"pivot"}]],[{"t":"f","v":"let"},{"t":"w","v":"left"},[{"t":"f","v":"if"},[{"t":"f","v":"="},{"t":"w","v":"predicate"},{"t":"a","v":0}],[{"t":"f","v":"merge"},{"t":"w","v":"a"},[{"t":"f","v":"Array"},{"t":"w","v":"current"}]],{"t":"w","v":"a"}]],[{"t":"f","v":"let"},{"t":"w","v":"right"},[{"t":"f","v":"if"},[{"t":"f","v":"="},{"t":"w","v":"predicate"},{"t":"a","v":1}],[{"t":"f","v":"merge"},{"t":"w","v":"b"},[{"t":"f","v":"Array"},{"t":"w","v":"current"}]],{"t":"w","v":"b"}]],[{"t":"f","v":"if"},[{"t":"f","v":"<"},{"t":"w","v":"i"},{"t":"w","v":"bounds"}],[{"t":"f","v":"iterate"},[{"t":"f","v":"+"},{"t":"w","v":"i"},{"t":"a","v":1}],{"t":"w","v":"bounds"},{"t":"w","v":"left"},{"t":"w","v":"right"}],[{"t":"f","v":"Array"},{"t":"w","v":"left"},{"t":"w","v":"right"}]]]]],[{"t":"f","v":"let"},{"t":"w","v":"sorted"},[{"t":"f","v":"iterate"},{"t":"a","v":1},[{"t":"f","v":"-"},[{"t":"f","v":"length"},{"t":"w","v":"arr"}],{"t":"a","v":1}],[],[]]],[{"t":"f","v":"let"},{"t":"w","v":"left"},[{"t":"f","v":"car"},{"t":"w","v":"sorted"}]],[{"t":"f","v":"let"},{"t":"w","v":"right"},[{"t":"f","v":"car"},[{"t":"f","v":"cdr"},{"t":"w","v":"sorted"}]]],[{"t":"f","v":"merge"},[{"t":"f","v":"sort"},{"t":"w","v":"left"},{"t":"w","v":"callback"}],[{"t":"f","v":"Array"},{"t":"w","v":"pivot"}],[{"t":"f","v":"sort"},{"t":"w","v":"right"},{"t":"w","v":"callback"}]]]]]]]]
1
+ export default [[{"t":"f","v":"let"},{"t":"w","v":"E"},{"t":"a","v":2.718281828459045}],[{"t":"f","v":"let"},{"t":"w","v":"PI"},{"t":"a","v":3.141592653589793}],[{"t":"f","v":"let*"},{"t":"w","v":"iteration"},[{"t":"f","v":"lambda"},{"t":"w","v":"arr"},{"t":"w","v":"callback"},[{"t":"f","v":"when"},[{"t":"f","v":"length"},{"t":"w","v":"arr"}],[{"t":"f","v":"do"},[{"t":"f","v":"callback"},[{"t":"f","v":"car"},{"t":"w","v":"arr"}]],[{"t":"f","v":"iteration"},[{"t":"f","v":"cdr"},{"t":"w","v":"arr"}],{"t":"w","v":"callback"}]]]]],[{"t":"f","v":"let"},{"t":"w","v":"scan"},[{"t":"f","v":"lambda"},{"t":"w","v":"arr"},{"t":"w","v":"callback"},[{"t":"f","v":"do"},[{"t":"f","v":"let*"},{"t":"w","v":"iterate"},[{"t":"f","v":"lambda"},{"t":"w","v":"arr"},{"t":"w","v":"out"},[{"t":"f","v":"if"},[{"t":"f","v":"length"},{"t":"w","v":"arr"}],[{"t":"f","v":"iterate"},[{"t":"f","v":"cdr"},{"t":"w","v":"arr"}],[{"t":"f","v":"merge"},{"t":"w","v":"out"},[{"t":"f","v":"Array"},[{"t":"f","v":"callback"},[{"t":"f","v":"car"},{"t":"w","v":"arr"}]]]]],{"t":"w","v":"out"}]]],[{"t":"f","v":"iterate"},{"t":"w","v":"arr"},[]]]]],[{"t":"f","v":"let"},{"t":"w","v":"select"},[{"t":"f","v":"lambda"},{"t":"w","v":"arr"},{"t":"w","v":"callback"},[{"t":"f","v":"do"},[{"t":"f","v":"let*"},{"t":"w","v":"iterate"},[{"t":"f","v":"lambda"},{"t":"w","v":"arr"},{"t":"w","v":"out"},[{"t":"f","v":"if"},[{"t":"f","v":"length"},{"t":"w","v":"arr"}],[{"t":"f","v":"iterate"},[{"t":"f","v":"cdr"},{"t":"w","v":"arr"}],[{"t":"f","v":"if"},[{"t":"f","v":"callback"},[{"t":"f","v":"car"},{"t":"w","v":"arr"}]],[{"t":"f","v":"merge"},{"t":"w","v":"out"},[{"t":"f","v":"Array"},[{"t":"f","v":"car"},{"t":"w","v":"arr"}]]],{"t":"w","v":"out"}]],{"t":"w","v":"out"}]]],[{"t":"f","v":"iterate"},{"t":"w","v":"arr"},[]]]]],[{"t":"f","v":"let"},{"t":"w","v":"exclude"},[{"t":"f","v":"lambda"},{"t":"w","v":"arr"},{"t":"w","v":"callback"},[{"t":"f","v":"do"},[{"t":"f","v":"let*"},{"t":"w","v":"iterate"},[{"t":"f","v":"lambda"},{"t":"w","v":"arr"},{"t":"w","v":"out"},[{"t":"f","v":"if"},[{"t":"f","v":"length"},{"t":"w","v":"arr"}],[{"t":"f","v":"iterate"},[{"t":"f","v":"cdr"},{"t":"w","v":"arr"}],[{"t":"f","v":"if"},[{"t":"f","v":"not"},[{"t":"f","v":"callback"},[{"t":"f","v":"car"},{"t":"w","v":"arr"}]]],[{"t":"f","v":"merge"},{"t":"w","v":"out"},[{"t":"f","v":"Array"},[{"t":"f","v":"car"},{"t":"w","v":"arr"}]]],{"t":"w","v":"out"}]],{"t":"w","v":"out"}]]],[{"t":"f","v":"iterate"},{"t":"w","v":"arr"},[]]]]],[{"t":"f","v":"let"},{"t":"w","v":"fold"},[{"t":"f","v":"lambda"},{"t":"w","v":"arr"},{"t":"w","v":"callback"},{"t":"w","v":"initial"},[{"t":"f","v":"do"},[{"t":"f","v":"let*"},{"t":"w","v":"iterate"},[{"t":"f","v":"lambda"},{"t":"w","v":"arr"},{"t":"w","v":"out"},[{"t":"f","v":"if"},[{"t":"f","v":"length"},{"t":"w","v":"arr"}],[{"t":"f","v":"iterate"},[{"t":"f","v":"cdr"},{"t":"w","v":"arr"}],[{"t":"f","v":"callback"},{"t":"w","v":"out"},[{"t":"f","v":"car"},{"t":"w","v":"arr"}]]],{"t":"w","v":"out"}]]],[{"t":"f","v":"iterate"},{"t":"w","v":"arr"},{"t":"w","v":"initial"}]]]],[{"t":"f","v":"let"},{"t":"w","v":"every?"},[{"t":"f","v":"lambda"},{"t":"w","v":"arr"},{"t":"w","v":"callback"},[{"t":"f","v":"do"},[{"t":"f","v":"let*"},{"t":"w","v":"iterate"},[{"t":"f","v":"lambda"},{"t":"w","v":"arr"},[{"t":"f","v":"if"},[{"t":"f","v":"and"},[{"t":"f","v":"length"},{"t":"w","v":"arr"}],[{"t":"f","v":"callback"},[{"t":"f","v":"car"},{"t":"w","v":"arr"}]]],[{"t":"f","v":"iterate"},[{"t":"f","v":"cdr"},{"t":"w","v":"arr"}]],[{"t":"f","v":"not"},[{"t":"f","v":"length"},{"t":"w","v":"arr"}]]]]],[{"t":"f","v":"iterate"},{"t":"w","v":"arr"}]]]],[{"t":"f","v":"let"},{"t":"w","v":"some?"},[{"t":"f","v":"lambda"},{"t":"w","v":"arr"},{"t":"w","v":"callback"},[{"t":"f","v":"do"},[{"t":"f","v":"let*"},{"t":"w","v":"iterate"},[{"t":"f","v":"lambda"},{"t":"w","v":"arr"},[{"t":"f","v":"if"},[{"t":"f","v":"and"},[{"t":"f","v":"length"},{"t":"w","v":"arr"}],[{"t":"f","v":"not"},[{"t":"f","v":"callback"},[{"t":"f","v":"car"},{"t":"w","v":"arr"}]]]],[{"t":"f","v":"iterate"},[{"t":"f","v":"cdr"},{"t":"w","v":"arr"}]],[{"t":"f","v":"type"},[{"t":"f","v":"length"},{"t":"w","v":"arr"}],{"t":"w","v":"Boolean"}]]]],[{"t":"f","v":"iterate"},{"t":"w","v":"arr"}]]]],[{"t":"f","v":"let"},{"t":"w","v":"find"},[{"t":"f","v":"lambda"},{"t":"w","v":"arr"},{"t":"w","v":"callback"},[{"t":"f","v":"do"},[{"t":"f","v":"let*"},{"t":"w","v":"iterate"},[{"t":"f","v":"lambda"},{"t":"w","v":"arr"},[{"t":"f","v":"when"},[{"t":"f","v":"length"},{"t":"w","v":"arr"}],[{"t":"f","v":"if"},[{"t":"f","v":"callback"},[{"t":"f","v":"car"},{"t":"w","v":"arr"}]],[{"t":"f","v":"car"},{"t":"w","v":"arr"}],[{"t":"f","v":"iterate"},[{"t":"f","v":"cdr"},{"t":"w","v":"arr"}]]]]]],[{"t":"f","v":"iterate"},{"t":"w","v":"arr"}]]]],[{"t":"f","v":"let"},{"t":"w","v":"has?"},[{"t":"f","v":"lambda"},{"t":"w","v":"arr"},{"t":"w","v":"callback"},[{"t":"f","v":"do"},[{"t":"f","v":"let*"},{"t":"w","v":"iterate"},[{"t":"f","v":"lambda"},{"t":"w","v":"arr"},[{"t":"f","v":"when"},[{"t":"f","v":"length"},{"t":"w","v":"arr"}],[{"t":"f","v":"if"},[{"t":"f","v":"callback"},[{"t":"f","v":"car"},{"t":"w","v":"arr"}]],{"t":"a","v":1},[{"t":"f","v":"iterate"},[{"t":"f","v":"cdr"},{"t":"w","v":"arr"}]]]]]],[{"t":"f","v":"iterate"},{"t":"w","v":"arr"}]]]],[{"t":"f","v":"let"},{"t":"w","v":"reverse"},[{"t":"f","v":"lambda"},{"t":"w","v":"arr"},[{"t":"f","v":"do"},[{"t":"f","v":"let*"},{"t":"w","v":"iterate"},[{"t":"f","v":"lambda"},{"t":"w","v":"arr"},{"t":"w","v":"out"},[{"t":"f","v":"if"},[{"t":"f","v":"length"},{"t":"w","v":"arr"}],[{"t":"f","v":"iterate"},[{"t":"f","v":"cdr"},{"t":"w","v":"arr"}],[{"t":"f","v":"merge"},[{"t":"f","v":"Array"},[{"t":"f","v":"car"},{"t":"w","v":"arr"}]],{"t":"w","v":"out"}]],{"t":"w","v":"out"}]]],[{"t":"f","v":"iterate"},{"t":"w","v":"arr"},[]]]]],[{"t":"f","v":"let"},{"t":"w","v":"range"},[{"t":"f","v":"lambda"},{"t":"w","v":"start"},{"t":"w","v":"end"},[{"t":"f","v":"do"},[{"t":"f","v":"let*"},{"t":"w","v":"iterate"},[{"t":"f","v":"lambda"},{"t":"w","v":"out"},{"t":"w","v":"count"},[{"t":"f","v":"if"},[{"t":"f","v":"<="},{"t":"w","v":"count"},{"t":"w","v":"end"}],[{"t":"f","v":"iterate"},[{"t":"f","v":"merge"},{"t":"w","v":"out"},[{"t":"f","v":"Array"},{"t":"w","v":"count"}]],[{"t":"f","v":"+"},{"t":"w","v":"count"},{"t":"a","v":1}]],{"t":"w","v":"out"}]]],[{"t":"f","v":"iterate"},[],{"t":"w","v":"start"}]]]],[{"t":"f","v":"let"},{"t":"w","v":"sequence"},[{"t":"f","v":"lambda"},{"t":"w","v":"arr"},[{"t":"f","v":"do"},[{"t":"f","v":"let"},{"t":"w","v":"end"},[{"t":"f","v":"length"},{"t":"w","v":"arr"}]],[{"t":"f","v":"let*"},{"t":"w","v":"iterate"},[{"t":"f","v":"lambda"},{"t":"w","v":"out"},{"t":"w","v":"count"},[{"t":"f","v":"if"},[{"t":"f","v":"<"},[{"t":"f","v":"length"},{"t":"w","v":"out"}],{"t":"w","v":"end"}],[{"t":"f","v":"iterate"},[{"t":"f","v":"merge"},{"t":"w","v":"out"},[{"t":"f","v":"Array"},{"t":"w","v":"count"}]],[{"t":"f","v":"+"},{"t":"w","v":"count"},{"t":"a","v":1}]],{"t":"w","v":"out"}]]],[{"t":"f","v":"iterate"},[],{"t":"a","v":0}]]]],[{"t":"f","v":"let"},{"t":"w","v":"sequence-n"},[{"t":"f","v":"lambda"},{"t":"w","v":"n"},[{"t":"f","v":"do"},[{"t":"f","v":"let*"},{"t":"w","v":"iterate"},[{"t":"f","v":"lambda"},{"t":"w","v":"out"},{"t":"w","v":"count"},[{"t":"f","v":"if"},[{"t":"f","v":"<"},[{"t":"f","v":"length"},{"t":"w","v":"out"}],{"t":"w","v":"n"}],[{"t":"f","v":"iterate"},[{"t":"f","v":"merge"},{"t":"w","v":"out"},[{"t":"f","v":"Array"},{"t":"w","v":"count"}]],[{"t":"f","v":"+"},{"t":"w","v":"count"},{"t":"a","v":1}]],{"t":"w","v":"out"}]]],[{"t":"f","v":"iterate"},[],{"t":"a","v":0}]]]],[{"t":"f","v":"let"},{"t":"w","v":"unique"},[{"t":"f","v":"lambda"},{"t":"w","v":"arr"},[{"t":"f","v":"go"},[{"t":"f","v":"let"},{"t":"w","v":"sorted"},[{"t":"f","v":"sort"},{"t":"w","v":"arr"},[{"t":"f","v":"safety"},{"t":"w","v":"lambda"},{"t":"w","v":"a"},{"t":"w","v":"b"},[{"t":"f","v":">"},{"t":"w","v":"a"},{"t":"w","v":"b"}]]]],[{"t":"f","v":"zip"},[{"t":"f","v":"sequence"},{"t":"w","v":"sorted"}]],[{"t":"f","v":"select"},[{"t":"f","v":"lambda"},{"t":"w","v":"x"},[{"t":"f","v":"or"},[{"t":"f","v":"not"},[{"t":"f","v":"let"},{"t":"w","v":"index"},[{"t":"f","v":"car"},[{"t":"f","v":"cdr"},{"t":"w","v":"x"}]]]],[{"t":"f","v":"not"},[{"t":"f","v":"="},[{"t":"f","v":"get"},{"t":"w","v":"sorted"},[{"t":"f","v":"-"},{"t":"w","v":"index"},{"t":"a","v":1}]],[{"t":"f","v":"get"},{"t":"w","v":"sorted"},{"t":"w","v":"index"}]]]]]],[{"t":"f","v":"scan"},{"t":"w","v":"car"}]]]],[{"t":"f","v":"let"},{"t":"w","v":"for-range"},[{"t":"f","v":"lambda"},{"t":"w","v":"start"},{"t":"w","v":"end"},{"t":"w","v":"callback"},[{"t":"f","v":"do"},[{"t":"f","v":"let*"},{"t":"w","v":"iterate"},[{"t":"f","v":"lambda"},{"t":"w","v":"i"},[{"t":"f","v":"when"},[{"t":"f","v":"<"},{"t":"w","v":"i"},{"t":"w","v":"end"}],[{"t":"f","v":"do"},[{"t":"f","v":"callback"},{"t":"w","v":"i"}],[{"t":"f","v":"iterate"},[{"t":"f","v":"+"},{"t":"w","v":"i"},{"t":"a","v":1}]]]]]],[{"t":"f","v":"iterate"},{"t":"w","v":"start"}]]]],[{"t":"f","v":"let"},{"t":"w","v":"list-range"},[{"t":"f","v":"lambda"},{"t":"w","v":"start"},{"t":"w","v":"end"},[{"t":"f","v":"do"},[{"t":"f","v":"let"},{"t":"w","v":"range"},[{"t":"f","v":"lambda"},{"t":"w","v":"list"},{"t":"w","v":"start"},{"t":"w","v":"end"},[{"t":"f","v":"if"},[{"t":"f","v":"<"},{"t":"w","v":"start"},{"t":"w","v":"end"}],[{"t":"f","v":"Array"},[{"t":"f","v":"merge"},{"t":"w","v":"list"},[{"t":"f","v":"range"},[{"t":"f","v":"Array"},[{"t":"f","v":"Array"},[{"t":"f","v":"+"},{"t":"w","v":"start"},{"t":"a","v":1}]]],[{"t":"f","v":"+"},{"t":"w","v":"start"},{"t":"a","v":1}],{"t":"w","v":"end"}]]],{"t":"w","v":"list"}]]],[{"t":"f","v":"car"},[{"t":"f","v":"car"},[{"t":"f","v":"range"},[],{"t":"w","v":"start"},{"t":"w","v":"end"}]]]]]],[{"t":"f","v":"let"},{"t":"w","v":"traverse"},[{"t":"f","v":"lambda"},{"t":"w","v":"x"},{"t":"w","v":"callback"},[{"t":"f","v":"if"},[{"t":"f","v":"Atom?"},{"t":"w","v":"x"}],[{"t":"f","v":"callback"},{"t":"w","v":"x"}],[{"t":"f","v":"iterate"},{"t":"w","v":"x"},[{"t":"f","v":"lambda"},{"t":"w","v":"y"},[{"t":"f","v":"traverse"},{"t":"w","v":"y"},{"t":"w","v":"callback"}]]]]]],[{"t":"f","v":"let"},{"t":"w","v":"summation"},[{"t":"f","v":"lambda"},{"t":"w","v":"arr"},[{"t":"f","v":"fold"},{"t":"w","v":"arr"},[{"t":"f","v":"safety"},{"t":"w","v":"lambda"},{"t":"w","v":"a"},{"t":"w","v":"b"},[{"t":"f","v":"+"},{"t":"w","v":"a"},{"t":"w","v":"b"}]],{"t":"a","v":0}]]],[{"t":"f","v":"let"},{"t":"w","v":"product"},[{"t":"f","v":"lambda"},{"t":"w","v":"arr"},[{"t":"f","v":"fold"},{"t":"w","v":"arr"},[{"t":"f","v":"safety"},{"t":"w","v":"lambda"},{"t":"w","v":"a"},{"t":"w","v":"b"},[{"t":"f","v":"*"},{"t":"w","v":"a"},{"t":"w","v":"b"}]],{"t":"a","v":1}]]],[{"t":"f","v":"let"},{"t":"w","v":"maximum"},[{"t":"f","v":"lambda"},{"t":"w","v":"arr"},[{"t":"f","v":"fold"},{"t":"w","v":"arr"},[{"t":"f","v":"safety"},{"t":"w","v":"lambda"},{"t":"w","v":"a"},{"t":"w","v":"b"},[{"t":"f","v":"if"},[{"t":"f","v":">"},{"t":"w","v":"a"},{"t":"w","v":"b"}],{"t":"w","v":"a"},{"t":"w","v":"b"}]],[{"t":"f","v":"car"},{"t":"w","v":"arr"}]]]],[{"t":"f","v":"let"},{"t":"w","v":"minimum"},[{"t":"f","v":"lambda"},{"t":"w","v":"arr"},[{"t":"f","v":"fold"},{"t":"w","v":"arr"},[{"t":"f","v":"safety"},{"t":"w","v":"lambda"},{"t":"w","v":"a"},{"t":"w","v":"b"},[{"t":"f","v":"if"},[{"t":"f","v":"<"},{"t":"w","v":"a"},{"t":"w","v":"b"}],{"t":"w","v":"a"},{"t":"w","v":"b"}]],[{"t":"f","v":"car"},{"t":"w","v":"arr"}]]]],[{"t":"f","v":"let"},{"t":"w","v":"max"},[{"t":"f","v":"lambda"},{"t":"w","v":"a"},{"t":"w","v":"b"},[{"t":"f","v":"if"},[{"t":"f","v":">"},{"t":"w","v":"a"},{"t":"w","v":"b"}],{"t":"w","v":"a"},{"t":"w","v":"b"}]]],[{"t":"f","v":"let"},{"t":"w","v":"min"},[{"t":"f","v":"lambda"},{"t":"w","v":"a"},{"t":"w","v":"b"},[{"t":"f","v":"if"},[{"t":"f","v":"<"},{"t":"w","v":"a"},{"t":"w","v":"b"}],{"t":"w","v":"a"},{"t":"w","v":"b"}]]],[{"t":"f","v":"let"},{"t":"w","v":"count-of"},[{"t":"f","v":"lambda"},{"t":"w","v":"arr"},{"t":"w","v":"callback"},[{"t":"f","v":"go"},{"t":"w","v":"arr"},[{"t":"f","v":"select"},{"t":"w","v":"callback"}],[{"t":"f","v":"length"}]]]],[{"t":"f","v":"let"},{"t":"w","v":"increment"},[{"t":"f","v":"safety"},{"t":"w","v":"lambda"},{"t":"w","v":"i"},[{"t":"f","v":"+"},{"t":"w","v":"i"},{"t":"a","v":1}]]],[{"t":"f","v":"let"},{"t":"w","v":"floor"},[{"t":"f","v":"safety"},{"t":"w","v":"lambda"},{"t":"w","v":"n"},[{"t":"f","v":"|"},{"t":"w","v":"n"},{"t":"a","v":0}]]],[{"t":"f","v":"let"},{"t":"w","v":"round"},[{"t":"f","v":"safety"},{"t":"w","v":"lambda"},{"t":"w","v":"n"},[{"t":"f","v":"|"},[{"t":"f","v":"+"},{"t":"w","v":"n"},{"t":"a","v":0.5}],{"t":"a","v":0}]]],[{"t":"f","v":"let"},{"t":"w","v":"empty?"},[{"t":"f","v":"safety"},{"t":"w","v":"lambda"},{"t":"w","v":"arr"},[{"t":"f","v":"not"},[{"t":"f","v":"length"},{"t":"w","v":"arr"}]]]],[{"t":"f","v":"let"},{"t":"w","v":"Array-in-bounds?"},[{"t":"f","v":"safety"},{"t":"w","v":"lambda"},{"t":"w","v":"arr"},{"t":"w","v":"index"},[{"t":"f","v":"and"},[{"t":"f","v":"<"},{"t":"w","v":"index"},[{"t":"f","v":"length"},{"t":"w","v":"arr"}]],[{"t":"f","v":">="},{"t":"w","v":"index"},{"t":"a","v":0}]]]],[{"t":"f","v":"let"},{"t":"w","v":"String->Array"},[{"t":"f","v":"safety"},{"t":"w","v":"lambda"},{"t":"w","v":"str"},[{"t":"f","v":"type"},{"t":"w","v":"str"},{"t":"w","v":"Array"}]]],[{"t":"f","v":"let"},{"t":"w","v":"Array->String"},[{"t":"f","v":"lambda"},{"t":"w","v":"arr"},[{"t":"f","v":"fold"},{"t":"w","v":"arr"},[{"t":"f","v":"safety"},{"t":"w","v":"lambda"},{"t":"w","v":"a"},{"t":"w","v":"x"},[{"t":"f","v":"concatenate"},{"t":"w","v":"a"},[{"t":"f","v":"type"},{"t":"w","v":"x"},{"t":"w","v":"String"}]]],{"t":"a","v":""}]]],[{"t":"f","v":"let"},{"t":"w","v":"String->Number"},[{"t":"f","v":"safety"},{"t":"w","v":"lambda"},{"t":"w","v":"str"},[{"t":"f","v":"type"},{"t":"w","v":"str"},{"t":"w","v":"Number"}]]],[{"t":"f","v":"let"},{"t":"w","v":"Number->String"},[{"t":"f","v":"safety"},{"t":"w","v":"lambda"},{"t":"w","v":"number"},[{"t":"f","v":"type"},{"t":"w","v":"number"},{"t":"w","v":"String"}]]],[{"t":"f","v":"let"},{"t":"w","v":"Strings->Numbers"},[{"t":"f","v":"lambda"},{"t":"w","v":"arr"},[{"t":"f","v":"scan"},{"t":"w","v":"arr"},[{"t":"f","v":"safety"},{"t":"w","v":"lambda"},{"t":"w","v":"x"},[{"t":"f","v":"type"},{"t":"w","v":"x"},{"t":"w","v":"Number"}]]]]],[{"t":"f","v":"let"},{"t":"w","v":"Numbers->Strings"},[{"t":"f","v":"lambda"},{"t":"w","v":"arr"},[{"t":"f","v":"scan"},{"t":"w","v":"arr"},[{"t":"f","v":"safety"},{"t":"w","v":"lambda"},{"t":"w","v":"x"},[{"t":"f","v":"type"},{"t":"w","v":"x"},{"t":"w","v":"String"}]]]]],[{"t":"f","v":"let"},{"t":"w","v":"String->Char-Codes"},[{"t":"f","v":"lambda"},{"t":"w","v":"str"},[{"t":"f","v":"go"},{"t":"w","v":"str"},[{"t":"f","v":"type"},{"t":"w","v":"Array"}],[{"t":"f","v":"scan"},[{"t":"f","v":"lambda"},{"t":"w","v":"x"},[{"t":"f","v":"type"},{"t":"w","v":"x"},{"t":"w","v":"Char-Code"}]]]]]],[{"t":"f","v":"let"},{"t":"w","v":"Chars->Char-Codes"},[{"t":"f","v":"lambda"},{"t":"w","v":"arr"},[{"t":"f","v":"go"},{"t":"w","v":"arr"},[{"t":"f","v":"scan"},[{"t":"f","v":"lambda"},{"t":"w","v":"x"},[{"t":"f","v":"type"},{"t":"w","v":"x"},{"t":"w","v":"Char-Code"}]]]]]],[{"t":"f","v":"let"},{"t":"w","v":"Char-Codes->Chars"},[{"t":"f","v":"lambda"},{"t":"w","v":"arr"},[{"t":"f","v":"go"},{"t":"w","v":"arr"},[{"t":"f","v":"scan"},[{"t":"f","v":"lambda"},{"t":"w","v":"x"},[{"t":"f","v":"type"},{"t":"w","v":"x"},{"t":"w","v":"Char"}]]]]]],[{"t":"f","v":"let"},{"t":"w","v":"Char-Codes->String"},[{"t":"f","v":"lambda"},{"t":"w","v":"arr"},[{"t":"f","v":"go"},{"t":"w","v":"arr"},[{"t":"f","v":"scan"},[{"t":"f","v":"lambda"},{"t":"w","v":"x"},[{"t":"f","v":"type"},{"t":"w","v":"x"},{"t":"w","v":"Char"}]]],[{"t":"f","v":"Array->String"}]]]],[{"t":"f","v":"let"},{"t":"w","v":"power"},[{"t":"f","v":"lambda"},{"t":"w","v":"base"},{"t":"w","v":"exp"},[{"t":"f","v":"if"},[{"t":"f","v":"<"},{"t":"w","v":"exp"},{"t":"a","v":0}],[{"t":"f","v":"if"},[{"t":"f","v":"="},{"t":"w","v":"base"},{"t":"a","v":0}],[{"t":"f","v":"throw"},{"t":"a","v":"Attempting to divide by 0 in (power)"}],[{"t":"f","v":"/"},[{"t":"f","v":"*"},{"t":"w","v":"base"},[{"t":"f","v":"power"},{"t":"w","v":"base"},[{"t":"f","v":"-"},[{"t":"f","v":"*"},{"t":"w","v":"exp"},{"t":"a","v":-1}],{"t":"a","v":1}]]]]],[{"t":"f","v":"cond"},[{"t":"f","v":"="},{"t":"w","v":"exp"},{"t":"a","v":0}],{"t":"a","v":1},[{"t":"f","v":"="},{"t":"w","v":"exp"},{"t":"a","v":1}],{"t":"w","v":"base"},[{"t":"f","v":"*"}],[{"t":"f","v":"*"},{"t":"w","v":"base"},[{"t":"f","v":"power"},{"t":"w","v":"base"},[{"t":"f","v":"-"},{"t":"w","v":"exp"},{"t":"a","v":1}]]]]]]],[{"t":"f","v":"let"},{"t":"w","v":"greatest-common-divisor"},[{"t":"f","v":"lambda"},{"t":"w","v":"a"},{"t":"w","v":"b"},[{"t":"f","v":"do"},[{"t":"f","v":"let*"},{"t":"w","v":"gcd"},[{"t":"f","v":"lambda"},{"t":"w","v":"a"},{"t":"w","v":"b"},[{"t":"f","v":"if"},[{"t":"f","v":"="},{"t":"w","v":"b"},{"t":"a","v":0}],{"t":"w","v":"a"},[{"t":"f","v":"gcd"},{"t":"w","v":"b"},[{"t":"f","v":"mod"},{"t":"w","v":"a"},{"t":"w","v":"b"}]]]],[{"t":"f","v":"gcd"},{"t":"w","v":"a"},{"t":"w","v":"b"}]]]]],[{"t":"f","v":"let"},{"t":"w","v":"least-common-divisor"},[{"t":"f","v":"lambda"},{"t":"w","v":"a"},{"t":"w","v":"b"},[{"t":"f","v":"*"},{"t":"w","v":"a"},{"t":"w","v":"b"},[{"t":"f","v":"/"},[{"t":"f","v":"greatest-common-divisor"},{"t":"w","v":"a"},{"t":"w","v":"b"}]]]]],[{"t":"f","v":"let"},{"t":"w","v":"sqrt"},[{"t":"f","v":"lambda"},{"t":"w","v":"x"},[{"t":"f","v":"do"},[{"t":"f","v":"let"},{"t":"w","v":"is-good-enough"},[{"t":"f","v":"lambda"},{"t":"w","v":"g"},{"t":"w","v":"x"},[{"t":"f","v":"<"},[{"t":"f","v":"abs"},[{"t":"f","v":"-"},[{"t":"f","v":"square"},{"t":"w","v":"g"}],{"t":"w","v":"x"}]],{"t":"a","v":0.01}]],{"t":"w","v":"improve-guess"},[{"t":"f","v":"lambda"},{"t":"w","v":"g"},{"t":"w","v":"x"},[{"t":"f","v":"average"},{"t":"w","v":"g"},[{"t":"f","v":"*"},{"t":"w","v":"x"},[{"t":"f","v":"/"},{"t":"w","v":"g"}]]]]],[{"t":"f","v":"let*"},{"t":"w","v":"sqrt-iter"},[{"t":"f","v":"lambda"},{"t":"w","v":"g"},{"t":"w","v":"x"},[{"t":"f","v":"if"},[{"t":"f","v":"is-good-enough"},{"t":"w","v":"g"},{"t":"w","v":"x"}],{"t":"w","v":"g"},[{"t":"f","v":"sqrt-iter"},[{"t":"f","v":"improve-guess"},{"t":"w","v":"g"},{"t":"w","v":"x"}],{"t":"w","v":"x"}]]]],[{"t":"f","v":"sqrt-iter"},{"t":"a","v":1},{"t":"w","v":"x"}]]]],[{"t":"f","v":"let"},{"t":"w","v":"circumference"},[{"t":"f","v":"lambda"},{"t":"w","v":"radius"},[{"t":"f","v":"*"},{"t":"w","v":"PI"},[{"t":"f","v":"*"},{"t":"w","v":"radius"},{"t":"a","v":2}]]]],[{"t":"f","v":"let"},{"t":"w","v":"hypotenuse"},[{"t":"f","v":"lambda"},{"t":"w","v":"a"},{"t":"w","v":"b"},[{"t":"f","v":"sqrt"},[{"t":"f","v":"+"},[{"t":"f","v":"*"},{"t":"w","v":"a"},{"t":"w","v":"a"}],[{"t":"f","v":"*"},{"t":"w","v":"b"},{"t":"w","v":"b"}]]]]],[{"t":"f","v":"let"},{"t":"w","v":"abs"},[{"t":"f","v":"safety"},{"t":"w","v":"lambda"},{"t":"w","v":"n"},[{"t":"f","v":"-"},[{"t":"f","v":"^"},{"t":"w","v":"n"},[{"t":"f","v":">>"},{"t":"w","v":"n"},{"t":"a","v":31}]],[{"t":"f","v":">>"},{"t":"w","v":"n"},{"t":"a","v":31}]]]],[{"t":"f","v":"let"},{"t":"w","v":"nth-digit"},[{"t":"f","v":"lambda"},{"t":"w","v":"digit"},{"t":"w","v":"n"},[{"t":"f","v":"|"},[{"t":"f","v":"mod"},[{"t":"f","v":"/"},{"t":"w","v":"digit"},[{"t":"f","v":"power"},{"t":"a","v":10},[{"t":"f","v":"-"},{"t":"w","v":"n"},{"t":"a","v":1}]]],{"t":"a","v":10}],{"t":"a","v":0.5}]]],[{"t":"f","v":"let"},{"t":"w","v":"normalize"},[{"t":"f","v":"safety"},{"t":"w","v":"lambda"},{"t":"w","v":"value"},{"t":"w","v":"min"},{"t":"w","v":"max"},[{"t":"f","v":"*"},[{"t":"f","v":"-"},{"t":"w","v":"value"},{"t":"w","v":"min"}],[{"t":"f","v":"/"},[{"t":"f","v":"-"},{"t":"w","v":"max"},{"t":"w","v":"min"}]]]]],[{"t":"f","v":"let"},{"t":"w","v":"linear-interpolation"},[{"t":"f","v":"safety"},{"t":"w","v":"lambda"},{"t":"w","v":"a"},{"t":"w","v":"b"},{"t":"w","v":"n"},[{"t":"f","v":"+"},[{"t":"f","v":"*"},[{"t":"f","v":"-"},{"t":"a","v":1},{"t":"w","v":"n"}],{"t":"w","v":"a"}],[{"t":"f","v":"*"},{"t":"w","v":"n"},{"t":"w","v":"b"}]]]],[{"t":"f","v":"let"},{"t":"w","v":"gauss-sum"},[{"t":"f","v":"safety"},{"t":"w","v":"lambda"},{"t":"w","v":"n"},[{"t":"f","v":"*"},{"t":"w","v":"n"},[{"t":"f","v":"+"},{"t":"w","v":"n"},{"t":"a","v":1}],{"t":"a","v":0.5}]]],[{"t":"f","v":"let"},{"t":"w","v":"gauss-sum-sequance"},[{"t":"f","v":"safety"},{"t":"w","v":"lambda"},{"t":"w","v":"a"},{"t":"w","v":"b"},[{"t":"f","v":"*"},[{"t":"f","v":"+"},{"t":"w","v":"a"},{"t":"w","v":"b"}],[{"t":"f","v":"+"},[{"t":"f","v":"-"},{"t":"w","v":"b"},{"t":"w","v":"a"}],{"t":"a","v":1}],{"t":"a","v":0.5}]]],[{"t":"f","v":"let"},{"t":"w","v":"clamp"},[{"t":"f","v":"safety"},{"t":"w","v":"lambda"},{"t":"w","v":"x"},{"t":"w","v":"limit"},[{"t":"f","v":"if"},[{"t":"f","v":">"},{"t":"w","v":"x"},{"t":"w","v":"limit"}],{"t":"w","v":"limit"},{"t":"w","v":"x"}]]],[{"t":"f","v":"let"},{"t":"w","v":"odd?"},[{"t":"f","v":"safety"},{"t":"w","v":"lambda"},{"t":"w","v":"x"},[{"t":"f","v":"="},[{"t":"f","v":"mod"},{"t":"w","v":"x"},{"t":"a","v":2}],{"t":"a","v":1}]]],[{"t":"f","v":"let"},{"t":"w","v":"even?"},[{"t":"f","v":"safety"},{"t":"w","v":"lambda"},{"t":"w","v":"x"},[{"t":"f","v":"="},[{"t":"f","v":"mod"},{"t":"w","v":"x"},{"t":"a","v":2}],{"t":"a","v":0}]]],[{"t":"f","v":"let"},{"t":"w","v":"sign"},[{"t":"f","v":"safety"},{"t":"w","v":"lambda"},{"t":"w","v":"n"},[{"t":"f","v":"if"},[{"t":"f","v":"<"},{"t":"w","v":"n"},{"t":"a","v":0}],{"t":"a","v":-1},{"t":"a","v":1}]]],[{"t":"f","v":"let"},{"t":"w","v":"radians"},[{"t":"f","v":"lambda"},{"t":"w","v":"deg"},[{"t":"f","v":"*"},{"t":"w","v":"deg"},{"t":"w","v":"PI"},[{"t":"f","v":"/"},{"t":"a","v":180}]]]],[{"t":"f","v":"let"},{"t":"w","v":"average"},[{"t":"f","v":"safety"},{"t":"w","v":"lambda"},{"t":"w","v":"x"},{"t":"w","v":"y"},[{"t":"f","v":"*"},[{"t":"f","v":"+"},{"t":"w","v":"x"},{"t":"w","v":"y"}],{"t":"a","v":0.5}]]],[{"t":"f","v":"let"},{"t":"w","v":"euclidean-mod"},[{"t":"f","v":"safety"},{"t":"w","v":"lambda"},{"t":"w","v":"a"},{"t":"w","v":"b"},[{"t":"f","v":"mod"},[{"t":"f","v":"+"},[{"t":"f","v":"mod"},{"t":"w","v":"a"},{"t":"w","v":"b"}],{"t":"w","v":"b"}],{"t":"w","v":"b"}]]],[{"t":"f","v":"let"},{"t":"w","v":"euclidean-distance"},[{"t":"f","v":"lambda"},{"t":"w","v":"x1"},{"t":"w","v":"y1"},{"t":"w","v":"x2"},{"t":"w","v":"y2"},[{"t":"f","v":"do"},[{"t":"f","v":"let"},{"t":"w","v":"a"},[{"t":"f","v":"-"},{"t":"w","v":"x1"},{"t":"w","v":"x2"}]],[{"t":"f","v":"let"},{"t":"w","v":"b"},[{"t":"f","v":"-"},{"t":"w","v":"y1"},{"t":"w","v":"y2"}]],[{"t":"f","v":"sqrt"},[{"t":"f","v":"+"},[{"t":"f","v":"*"},{"t":"w","v":"a"},{"t":"w","v":"a"}],[{"t":"f","v":"*"},{"t":"w","v":"b"},{"t":"w","v":"b"}]]]]]],[{"t":"f","v":"let"},{"t":"w","v":"manhattan-distance"},[{"t":"f","v":"lambda"},{"t":"w","v":"x1"},{"t":"w","v":"y1"},{"t":"w","v":"x2"},{"t":"w","v":"y2"},[{"t":"f","v":"+"},[{"t":"f","v":"abs"},[{"t":"f","v":"-"},{"t":"w","v":"x2"},{"t":"w","v":"x1"}]],[{"t":"f","v":"abs"},[{"t":"f","v":"-"},{"t":"w","v":"y2"},{"t":"w","v":"y1"}]]]]],[{"t":"f","v":"let"},{"t":"w","v":"positive?"},[{"t":"f","v":"safety"},{"t":"w","v":"lambda"},{"t":"w","v":"num"},[{"t":"f","v":">"},{"t":"w","v":"num"},{"t":"a","v":0}]]],[{"t":"f","v":"let"},{"t":"w","v":"negative?"},[{"t":"f","v":"safety"},{"t":"w","v":"lambda"},{"t":"w","v":"num"},[{"t":"f","v":"<"},{"t":"w","v":"num"},{"t":"a","v":0}]]],[{"t":"f","v":"let"},{"t":"w","v":"zero?"},[{"t":"f","v":"safety"},{"t":"w","v":"lambda"},{"t":"w","v":"num"},[{"t":"f","v":"="},{"t":"w","v":"num"},{"t":"a","v":0}]]],[{"t":"f","v":"let"},{"t":"w","v":"divisible?"},[{"t":"f","v":"safety"},{"t":"w","v":"lambda"},{"t":"w","v":"a"},{"t":"w","v":"b"},[{"t":"f","v":"="},[{"t":"f","v":"mod"},{"t":"w","v":"a"},{"t":"w","v":"b"}],{"t":"a","v":0}]]],[{"t":"f","v":"let"},{"t":"w","v":"prime?"},[{"t":"f","v":"lambda"},{"t":"w","v":"n"},[{"t":"f","v":"cond"},[{"t":"f","v":"="},{"t":"w","v":"n"},{"t":"a","v":1}],{"t":"a","v":0},[{"t":"f","v":"<"},{"t":"w","v":"n"},{"t":"a","v":0}],{"t":"a","v":0},[{"t":"f","v":"*"}],[{"t":"f","v":"do"},[{"t":"f","v":"let*"},{"t":"w","v":"iter"},[{"t":"f","v":"lambda"},{"t":"w","v":"i"},{"t":"w","v":"end"},[{"t":"f","v":"do"},[{"t":"f","v":"let"},{"t":"w","v":"it-is"},[{"t":"f","v":"not"},[{"t":"f","v":"="},[{"t":"f","v":"mod"},{"t":"w","v":"n"},{"t":"w","v":"i"}],{"t":"a","v":0}]]],[{"t":"f","v":"if"},[{"t":"f","v":"and"},[{"t":"f","v":"<="},{"t":"w","v":"i"},{"t":"w","v":"end"}],{"t":"w","v":"it-is"}],[{"t":"f","v":"iter"},[{"t":"f","v":"+"},{"t":"w","v":"i"},{"t":"a","v":1}],{"t":"w","v":"end"}],{"t":"w","v":"it-is"}]]]],[{"t":"f","v":"or"},[{"t":"f","v":"="},{"t":"w","v":"n"},{"t":"a","v":2}],[{"t":"f","v":"iter"},{"t":"a","v":2},[{"t":"f","v":"sqrt"},{"t":"w","v":"n"}]]]]]]],[{"t":"f","v":"let"},{"t":"w","v":"slice"},[{"t":"f","v":"safety"},{"t":"w","v":"lambda"},{"t":"w","v":"arr"},{"t":"w","v":"start"},{"t":"w","v":"end"},[{"t":"f","v":"do"},[{"t":"f","v":"let"},{"t":"w","v":"bounds"},[{"t":"f","v":"-"},{"t":"w","v":"end"},{"t":"w","v":"start"}]],[{"t":"f","v":"let*"},{"t":"w","v":"iterate"},[{"t":"f","v":"lambda"},{"t":"w","v":"i"},{"t":"w","v":"out"},[{"t":"f","v":"if"},[{"t":"f","v":"<"},{"t":"w","v":"i"},{"t":"w","v":"bounds"}],[{"t":"f","v":"iterate"},[{"t":"f","v":"+"},{"t":"w","v":"i"},{"t":"a","v":1}],[{"t":"f","v":"merge"},{"t":"w","v":"out"},[{"t":"f","v":"Array"},[{"t":"f","v":"get"},{"t":"w","v":"arr"},[{"t":"f","v":"+"},{"t":"w","v":"start"},{"t":"w","v":"i"}]]]]],{"t":"w","v":"out"}]]],[{"t":"f","v":"iterate"},{"t":"a","v":0},[]]]]],[{"t":"f","v":"let"},{"t":"w","v":"binary-search"},[{"t":"f","v":"lambda"},{"t":"w","v":"arr"},{"t":"w","v":"target"},[{"t":"f","v":"do"},[{"t":"f","v":"let*"},{"t":"w","v":"search"},[{"t":"f","v":"lambda"},{"t":"w","v":"arr"},{"t":"w","v":"target"},{"t":"w","v":"start"},{"t":"w","v":"end"},[{"t":"f","v":"do"},[{"t":"f","v":"when"},[{"t":"f","v":"<="},{"t":"w","v":"start"},{"t":"w","v":"end"}],[{"t":"f","v":"do"},[{"t":"f","v":"let"},{"t":"w","v":"index"},[{"t":"f","v":"floor"},[{"t":"f","v":"*"},[{"t":"f","v":"+"},{"t":"w","v":"start"},{"t":"w","v":"end"}],{"t":"a","v":0.5}]]],[{"t":"f","v":"let"},{"t":"w","v":"current"},[{"t":"f","v":"get"},{"t":"w","v":"arr"},{"t":"w","v":"index"}]],[{"t":"f","v":"if"},[{"t":"f","v":"="},{"t":"w","v":"target"},{"t":"w","v":"current"}],{"t":"w","v":"target"},[{"t":"f","v":"if"},[{"t":"f","v":">"},{"t":"w","v":"current"},{"t":"w","v":"target"}],[{"t":"f","v":"search"},{"t":"w","v":"arr"},{"t":"w","v":"target"},{"t":"w","v":"start"},[{"t":"f","v":"-"},{"t":"w","v":"index"},{"t":"a","v":1}]],[{"t":"f","v":"search"},{"t":"w","v":"arr"},{"t":"w","v":"target"},[{"t":"f","v":"+"},{"t":"w","v":"index"},{"t":"a","v":1}],{"t":"w","v":"end"}]]]]]]]],[{"t":"f","v":"search"},{"t":"w","v":"arr"},{"t":"w","v":"target"},{"t":"a","v":0},[{"t":"f","v":"length"},{"t":"w","v":"arr"}]]]]],[{"t":"f","v":"let"},{"t":"w","v":"zip"},[{"t":"f","v":"safety"},{"t":"w","v":"lambda"},{"t":"w","v":"A"},{"t":"w","v":"B"},[{"t":"f","v":"do"},[{"t":"f","v":"let*"},{"t":"w","v":"iterate"},[{"t":"f","v":"lambda"},{"t":"w","v":"a"},{"t":"w","v":"b"},{"t":"w","v":"output"},[{"t":"f","v":"if"},[{"t":"f","v":"and"},[{"t":"f","v":"length"},{"t":"w","v":"a"}],[{"t":"f","v":"length"},{"t":"w","v":"b"}]],[{"t":"f","v":"iterate"},[{"t":"f","v":"cdr"},{"t":"w","v":"a"}],[{"t":"f","v":"cdr"},{"t":"w","v":"b"}],[{"t":"f","v":"merge"},{"t":"w","v":"output"},[{"t":"f","v":"Array"},[{"t":"f","v":"Array"},[{"t":"f","v":"car"},{"t":"w","v":"a"}],[{"t":"f","v":"car"},{"t":"w","v":"b"}]]]]],{"t":"w","v":"output"}]]],[{"t":"f","v":"iterate"},{"t":"w","v":"A"},{"t":"w","v":"B"},[]]]]],[{"t":"f","v":"let"},{"t":"w","v":"cartesian-product"},[{"t":"f","v":"lambda"},{"t":"w","v":"a"},{"t":"w","v":"b"},[{"t":"f","v":"fold"},{"t":"w","v":"a"},[{"t":"f","v":"lambda"},{"t":"w","v":"p"},{"t":"w","v":"x"},[{"t":"f","v":"merge"},{"t":"w","v":"p"},[{"t":"f","v":"scan"},{"t":"w","v":"b"},[{"t":"f","v":"lambda"},{"t":"w","v":"y"},[{"t":"f","v":"Array"},{"t":"w","v":"x"},{"t":"w","v":"y"}]]]]],[]]]],[{"t":"f","v":"let"},{"t":"w","v":"equal?"},[{"t":"f","v":"lambda"},{"t":"w","v":"a"},{"t":"w","v":"b"},[{"t":"f","v":"or"},[{"t":"f","v":"and"},[{"t":"f","v":"Atom?"},{"t":"w","v":"a"}],[{"t":"f","v":"Atom?"},{"t":"w","v":"b"}],[{"t":"f","v":"="},{"t":"w","v":"a"},{"t":"w","v":"b"}]],[{"t":"f","v":"and"},[{"t":"f","v":"Array?"},{"t":"w","v":"a"}],[{"t":"f","v":"="},[{"t":"f","v":"length"},{"t":"w","v":"a"}],[{"t":"f","v":"length"},{"t":"w","v":"b"}]],[{"t":"f","v":"not"},[{"t":"f","v":"some?"},[{"t":"f","v":"sequence"},{"t":"w","v":"a"}],[{"t":"f","v":"lambda"},{"t":"w","v":"i"},[{"t":"f","v":"not"},[{"t":"f","v":"equal?"},[{"t":"f","v":"get"},{"t":"w","v":"a"},{"t":"w","v":"i"}],[{"t":"f","v":"get"},{"t":"w","v":"b"},{"t":"w","v":"i"}]]]]]]]]]],[{"t":"f","v":"let"},{"t":"w","v":"split"},[{"t":"f","v":"lambda"},{"t":"w","v":"str"},{"t":"w","v":"delim"},[{"t":"f","v":"do"},[{"t":"f","v":"let"},{"t":"w","v":"input"},[{"t":"f","v":"type"},[{"t":"f","v":"concatenate"},{"t":"w","v":"str"},{"t":"w","v":"delim"}],{"t":"w","v":"Array"}]],[{"t":"f","v":"let"},{"t":"w","v":"marks"},[{"t":"f","v":"go"},{"t":"w","v":"input"},[{"t":"f","v":"zip"},[{"t":"f","v":"sequence"},{"t":"w","v":"input"}]],[{"t":"f","v":"scan"},[{"t":"f","v":"lambda"},{"t":"w","v":"x"},[{"t":"f","v":"if"},[{"t":"f","v":"="},[{"t":"f","v":"car"},{"t":"w","v":"x"}],{"t":"w","v":"delim"}],[{"t":"f","v":"car"},[{"t":"f","v":"cdr"},{"t":"w","v":"x"}]],[{"t":"f","v":"car"},{"t":"w","v":"x"}]]]]]],[{"t":"f","v":"let"},{"t":"w","v":"first"},[{"t":"f","v":"find"},{"t":"w","v":"marks"},[{"t":"f","v":"lambda"},{"t":"w","v":"x"},[{"t":"f","v":"Number?"},{"t":"w","v":"x"}]]]],[{"t":"f","v":"go"},{"t":"w","v":"marks"},[{"t":"f","v":"fold"},[{"t":"f","v":"lambda"},{"t":"w","v":"a"},{"t":"w","v":"b"},[{"t":"f","v":"if"},[{"t":"f","v":"Number?"},{"t":"w","v":"b"}],[{"t":"f","v":"merge"},{"t":"w","v":"a"},[{"t":"f","v":"Array"},[{"t":"f","v":"slice"},{"t":"w","v":"input"},[{"t":"f","v":"-"},{"t":"w","v":"b"},{"t":"w","v":"first"}],{"t":"w","v":"b"}]]],{"t":"w","v":"a"}]],[]],[{"t":"f","v":"scan"},[{"t":"f","v":"lambda"},{"t":"w","v":"x"},[{"t":"f","v":"Array->String"},{"t":"w","v":"x"}]]]]]]],[{"t":"f","v":"let"},{"t":"w","v":"join"},[{"t":"f","v":"lambda"},{"t":"w","v":"arr"},{"t":"w","v":"delim"},[{"t":"f","v":"fold"},[{"t":"f","v":"zip"},{"t":"w","v":"arr"},[{"t":"f","v":"sequence"},{"t":"w","v":"arr"}]],[{"t":"f","v":"lambda"},{"t":"w","v":"a"},{"t":"w","v":"b"},[{"t":"f","v":"if"},[{"t":"f","v":">"},[{"t":"f","v":"car"},[{"t":"f","v":"cdr"},{"t":"w","v":"b"}]],{"t":"a","v":0}],[{"t":"f","v":"concatenate"},{"t":"w","v":"a"},{"t":"w","v":"delim"},[{"t":"f","v":"type"},[{"t":"f","v":"car"},{"t":"w","v":"b"}],{"t":"w","v":"String"}]],[{"t":"f","v":"type"},[{"t":"f","v":"car"},{"t":"w","v":"b"}],{"t":"w","v":"String"}]]],{"t":"a","v":""}]]],[{"t":"f","v":"let"},{"t":"w","v":"flat"},[{"t":"f","v":"lambda"},{"t":"w","v":"arr"},[{"t":"f","v":"do"},[{"t":"f","v":"let"},{"t":"w","v":"flatten"},[{"t":"f","v":"lambda"},{"t":"w","v":"item"},[{"t":"f","v":"if"},[{"t":"f","v":"and"},[{"t":"f","v":"Array?"},{"t":"w","v":"item"}],[{"t":"f","v":"length"},{"t":"w","v":"item"}]],[{"t":"f","v":"fold"},{"t":"w","v":"item"},[{"t":"f","v":"lambda"},{"t":"w","v":"a"},{"t":"w","v":"b"},[{"t":"f","v":"merge"},{"t":"w","v":"a"},[{"t":"f","v":"flatten"},{"t":"w","v":"b"}]]],[]],[{"t":"f","v":"Array"},{"t":"w","v":"item"}]]]],[{"t":"f","v":"flatten"},{"t":"w","v":"arr"}]]]],[{"t":"f","v":"let"},{"t":"w","v":"sort"},[{"t":"f","v":"lambda"},{"t":"w","v":"arr"},{"t":"w","v":"callback"},[{"t":"f","v":"do"},[{"t":"f","v":"if"},[{"t":"f","v":"<="},[{"t":"f","v":"length"},{"t":"w","v":"arr"}],{"t":"a","v":1}],{"t":"w","v":"arr"},[{"t":"f","v":"do"},[{"t":"f","v":"let"},{"t":"w","v":"pivot"},[{"t":"f","v":"car"},{"t":"w","v":"arr"}]],[{"t":"f","v":"let*"},{"t":"w","v":"iterate"},[{"t":"f","v":"lambda"},{"t":"w","v":"i"},{"t":"w","v":"bounds"},{"t":"w","v":"a"},{"t":"w","v":"b"},[{"t":"f","v":"do"},[{"t":"f","v":"let"},{"t":"w","v":"current"},[{"t":"f","v":"get"},{"t":"w","v":"arr"},{"t":"w","v":"i"}]],[{"t":"f","v":"let"},{"t":"w","v":"predicate"},[{"t":"f","v":"callback"},{"t":"w","v":"current"},{"t":"w","v":"pivot"}]],[{"t":"f","v":"let"},{"t":"w","v":"left"},[{"t":"f","v":"if"},[{"t":"f","v":"="},{"t":"w","v":"predicate"},{"t":"a","v":0}],[{"t":"f","v":"merge"},{"t":"w","v":"a"},[{"t":"f","v":"Array"},{"t":"w","v":"current"}]],{"t":"w","v":"a"}]],[{"t":"f","v":"let"},{"t":"w","v":"right"},[{"t":"f","v":"if"},[{"t":"f","v":"="},{"t":"w","v":"predicate"},{"t":"a","v":1}],[{"t":"f","v":"merge"},{"t":"w","v":"b"},[{"t":"f","v":"Array"},{"t":"w","v":"current"}]],{"t":"w","v":"b"}]],[{"t":"f","v":"if"},[{"t":"f","v":"<"},{"t":"w","v":"i"},{"t":"w","v":"bounds"}],[{"t":"f","v":"iterate"},[{"t":"f","v":"+"},{"t":"w","v":"i"},{"t":"a","v":1}],{"t":"w","v":"bounds"},{"t":"w","v":"left"},{"t":"w","v":"right"}],[{"t":"f","v":"Array"},{"t":"w","v":"left"},{"t":"w","v":"right"}]]]]],[{"t":"f","v":"let"},{"t":"w","v":"sorted"},[{"t":"f","v":"iterate"},{"t":"a","v":1},[{"t":"f","v":"-"},[{"t":"f","v":"length"},{"t":"w","v":"arr"}],{"t":"a","v":1}],[],[]]],[{"t":"f","v":"let"},{"t":"w","v":"left"},[{"t":"f","v":"car"},{"t":"w","v":"sorted"}]],[{"t":"f","v":"let"},{"t":"w","v":"right"},[{"t":"f","v":"car"},[{"t":"f","v":"cdr"},{"t":"w","v":"sorted"}]]],[{"t":"f","v":"merge"},[{"t":"f","v":"sort"},{"t":"w","v":"left"},{"t":"w","v":"callback"}],[{"t":"f","v":"Array"},{"t":"w","v":"pivot"}],[{"t":"f","v":"sort"},{"t":"w","v":"right"},{"t":"w","v":"callback"}]]]]]]],[{"t":"f","v":"let"},{"t":"w","v":"set"},[{"t":"f","v":"lambda"},{"t":"w","v":"arr"},{"t":"w","v":"i"},{"t":"w","v":"value"},[{"t":"f","v":"if"},[{"t":"f","v":"Array-in-bounds?"},{"t":"w","v":"arr"},{"t":"w","v":"i"}],[{"t":"f","v":"scan"},[{"t":"f","v":"sequence"},{"t":"w","v":"arr"}],[{"t":"f","v":"lambda"},{"t":"w","v":"x"},[{"t":"f","v":"if"},[{"t":"f","v":"="},{"t":"w","v":"x"},{"t":"w","v":"i"}],{"t":"w","v":"value"},[{"t":"f","v":"get"},{"t":"w","v":"arr"},{"t":"w","v":"x"}]]]],[{"t":"f","v":"throw"},[{"t":"f","v":"concatenate"},[{"t":"f","v":"type"},{"t":"w","v":"i"},{"t":"w","v":"String"}],{"t":"a","v":" is outside of the arr bounds."}]]]]],[{"t":"f","v":"let"},{"t":"w","v":"adjacent-difference"},[{"t":"f","v":"lambda"},{"t":"w","v":"arr"},{"t":"w","v":"callback"},[{"t":"f","v":"do"},[{"t":"f","v":"let"},{"t":"w","v":"len"},[{"t":"f","v":"length"},{"t":"w","v":"arr"}]],[{"t":"f","v":"unless"},[{"t":"f","v":"="},{"t":"w","v":"len"},{"t":"a","v":1}],[{"t":"f","v":"do"},[{"t":"f","v":"Array"},[{"t":"f","v":"car"},{"t":"w","v":"arr"}]],[{"t":"f","v":"let*"},{"t":"w","v":"iterate"},[{"t":"f","v":"lambda"},{"t":"w","v":"i"},{"t":"w","v":"result"},[{"t":"f","v":"if"},[{"t":"f","v":"<"},{"t":"w","v":"i"},{"t":"w","v":"len"}],[{"t":"f","v":"do"},[{"t":"f","v":"iterate"},[{"t":"f","v":"+"},{"t":"w","v":"i"},{"t":"a","v":1}],[{"t":"f","v":"set"},{"t":"w","v":"result"},{"t":"w","v":"i"},[{"t":"f","v":"callback"},[{"t":"f","v":"get"},{"t":"w","v":"arr"},[{"t":"f","v":"-"},{"t":"w","v":"i"},{"t":"a","v":1}]],[{"t":"f","v":"get"},{"t":"w","v":"arr"},{"t":"w","v":"i"}]]]]],{"t":"w","v":"result"}]]],[{"t":"f","v":"iterate"},{"t":"a","v":1},{"t":"w","v":"arr"}]],{"t":"w","v":"arr"}]]]]]
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "fez-lisp",
3
3
  "description": "Immutable Lisp interpreted & compiled to JavaScript",
4
4
  "author": "AT290690",
5
- "version": "1.0.0",
5
+ "version": "1.0.2",
6
6
  "type": "module",
7
7
  "main": "index.js",
8
8
  "keywords": [
package/src/compiler.js CHANGED
@@ -20,32 +20,8 @@ return result
20
20
  error: `_error=(error)=>{
21
21
  throw new Error(error)
22
22
  }`,
23
- serialise: `_serialise=(result)=>{
24
- return typeof result==='function'?'(λ)':Array.isArray(result)?JSON.stringify(result,(_,value)=>{
25
- switch(typeof value){
26
- case 'number':
27
- return Number(value)
28
- case 'function':
29
- return 'λ'
30
- case 'undefined':
31
- case 'symbol':
32
- return 0
33
- case 'boolean':
34
- return +value
35
- default:
36
- return value
37
- }
38
- })
39
- .replace(new RegExp(/\\[/g),"(Array ")
40
- .replace(new RegExp(/\\]/g),')')
41
- .replace(new RegExp(/\\,/g),' ')
42
- .replace(new RegExp(/"λ"/g),'λ')
43
- :typeof result==='string'
44
- ?'"'+result+'"'
45
- :result==undefined
46
- ?'(void)'
47
- :result
48
- }`,
23
+ serialise:
24
+ "_serialise=(ast)=>{\n if(ast==undefined) return '()'\n else if(typeofast==='object')\n if(Array.isArray(ast)) return `(Array ${ast.map(stringify).join(' ')})`\n else\n return `(Array ${Object.entries(ast).map(([key, value]) => `(\"${key}\" ${stringify(value)})`).join(' ')})`\n else if(typeofast==='string') return `\"${ast}\"`\n else if(typeofast==='function') return '()'\n else return ast\n}",
49
25
  cast: `_cast=(type,value)=>{
50
26
  switch (type) {
51
27
  case 'Number':
package/src/enums.js CHANGED
@@ -12,7 +12,7 @@ export const KEYWORDS = {
12
12
  STRING_TYPE: 'String',
13
13
  NUMBER_TYPE: 'Number',
14
14
  BOOLEAN_TYPE: 'Boolean',
15
- FUNCTION_TYPE: 'Function',
15
+ FUNCTION_TYPE: 'Lambda',
16
16
  ARRAY_TYPE: 'Array',
17
17
  CHAR_CODE_TYPE: 'Char-Code',
18
18
  CHAR_TYPE: 'Char',
@@ -23,7 +23,7 @@ export const KEYWORDS = {
23
23
  IS_ARRAY: 'Array?',
24
24
  IS_NUMBER: 'Number?',
25
25
  IS_STRING: 'String?',
26
- IS_FUNCTION: 'Function?',
26
+ IS_FUNCTION: 'Lambda?',
27
27
 
28
28
  ADDITION: '+',
29
29
  SUBTRACTION: '-',
@@ -14,8 +14,14 @@ export const evaluate = (expression, env) => {
14
14
  }
15
15
  case APPLY:
16
16
  const apply = env[first[VALUE]]
17
+ if (apply == undefined)
18
+ throw new ReferenceError(
19
+ `Undefined (${KEYWORDS.ANONYMOUS_FUNCTION}) ${first[VALUE]}.`
20
+ )
17
21
  if (typeof apply !== 'function')
18
- throw new TypeError(`${first[VALUE]} is not a (function).`)
22
+ throw new TypeError(
23
+ `${first[VALUE]} is not a (${KEYWORDS.ANONYMOUS_FUNCTION}).`
24
+ )
19
25
  return apply(rest, env)
20
26
  case ATOM:
21
27
  return first[VALUE]
package/src/parser.js CHANGED
@@ -43,3 +43,15 @@ export const parse = (source) => {
43
43
  }
44
44
  return tree
45
45
  }
46
+ export const stringify = (ast) => {
47
+ if (ast == undefined) return '()'
48
+ else if (typeof ast === 'object')
49
+ if (Array.isArray(ast)) return `(Array ${ast.map(stringify).join(' ')})`
50
+ else
51
+ return `(Array ${Object.entries(ast)
52
+ .map(([key, value]) => `("${key}" ${stringify(value)})`)
53
+ .join(' ')})`
54
+ else if (typeof ast === 'string') return `"${ast}"`
55
+ else if (typeof ast === 'function') return '()'
56
+ else return ast
57
+ }
package/src/tokeniser.js CHANGED
@@ -1,11 +1,11 @@
1
1
  import { TYPE, VALUE, WORD, KEYWORDS } from './enums.js'
2
2
  import { evaluate } from './interpreter.js'
3
+ import { stringify } from './parser.js'
3
4
  import {
4
5
  isAtom,
5
6
  isEqual,
6
7
  isEqualTypes,
7
8
  isForbiddenVariableName,
8
- lispify,
9
9
  stringifyArgs,
10
10
  } from './utils.js'
11
11
 
@@ -1004,14 +1004,14 @@ const keywords = {
1004
1004
  '\x1b[31m',
1005
1005
  `${describe} Failed:\n`,
1006
1006
 
1007
- `${rest[0]} => ${lispify(rest[1])} != ${lispify(rest[2])}`,
1007
+ `${rest[0]} => ${stringify(rest[1])} != ${stringify(rest[2])}`,
1008
1008
  '\n',
1009
1009
  '\x1b[0m'
1010
1010
  )
1011
1011
  : console.log(
1012
1012
  '\x1b[32m',
1013
1013
  `${describe} Passed:\n`,
1014
- `${rest[0]} => ${lispify(rest[1])}`,
1014
+ `${rest[0]} => ${stringify(rest[1])}`,
1015
1015
  '\n',
1016
1016
  '\x1b[0m'
1017
1017
  )
@@ -1019,9 +1019,11 @@ const keywords = {
1019
1019
  } catch (err) {
1020
1020
  console.log('\x1b[31m', 'Tests failed: \n', err.toString())
1021
1021
  }
1022
- !tests.length || tests.some(([t]) => !t)
1022
+ const result = !tests.length || tests.some(([t]) => !t)
1023
+ result
1023
1024
  ? console.log('\x1b[31m', 'Some tests failed!', '\n', '\x1b[0m')
1024
1025
  : console.log('\x1b[32m', 'All tests passed!', '\n', '\x1b[0m')
1026
+ return +!result
1025
1027
  },
1026
1028
  [KEYWORDS.SERIALISE]: (args, env) => {
1027
1029
  if (!args.length)
@@ -1029,7 +1031,7 @@ const keywords = {
1029
1031
  `Invalid number of arguments for (${KEYWORDS.SERIALISE})`
1030
1032
  )
1031
1033
  const data = evaluate(args[0], env)
1032
- return lispify(data)
1034
+ return stringify(data)
1033
1035
  },
1034
1036
  }
1035
1037
  keywords[KEYWORDS.NOT_COMPILED_BLOCK] = keywords[KEYWORDS.BLOCK]
package/src/utils.js CHANGED
@@ -42,34 +42,6 @@ export const stringifyType = (type) =>
42
42
  Array.isArray(type)
43
43
  ? `(array ${type.map((t) => stringifyType(t)).join(' ')})`
44
44
  : typeof type
45
- export const lispify = (result) =>
46
- typeof result === 'function'
47
- ? `(λ)`
48
- : Array.isArray(result)
49
- ? JSON.stringify(result, (_, value) => {
50
- switch (typeof value) {
51
- case 'number':
52
- return Number(value)
53
- case 'function':
54
- return 'λ'
55
- case 'undefined':
56
- case 'symbol':
57
- return 0
58
- case 'boolean':
59
- return +value
60
- default:
61
- return value
62
- }
63
- })
64
- .replace(new RegExp(/\[/g), `(Array `)
65
- .replace(new RegExp(/\]/g), ')')
66
- .replace(new RegExp(/\,/g), ' ')
67
- .replace(new RegExp(/"λ"/g), 'λ')
68
- : typeof result === 'string'
69
- ? `"${result}"`
70
- : result == undefined
71
- ? '(void)'
72
- : result
73
45
  export const stringifyArgs = (args) =>
74
46
  args
75
47
  .map((x) =>
@@ -155,19 +127,28 @@ export const handleUnbalancedQuotes = (source) => {
155
127
  if (diff !== 0) throw new SyntaxError(`Quotes are unbalanced "`)
156
128
  return source
157
129
  }
130
+
158
131
  export const treeShake = (ast, libs) => {
159
132
  const deps = libs.reduce((a, x) => a.add(x.at(1)[VALUE]), new Set())
160
- const visited = new Map()
161
- const dfs = (tree) =>
162
- Array.isArray(tree)
163
- ? tree.forEach((a) => dfs(a))
164
- : (tree[TYPE] === APPLY || tree[TYPE] === WORD) &&
165
- deps.has(tree[VALUE]) &&
166
- visited.set(tree[VALUE], tree[VALUE])
133
+ const visited = new Set()
134
+ const dfs = (tree) => {
135
+ if (Array.isArray(tree)) tree.forEach((a) => dfs(a))
136
+ else if (
137
+ (tree[TYPE] === APPLY || tree[TYPE] === WORD) &&
138
+ deps.has(tree[VALUE]) &&
139
+ !visited.has(tree[VALUE])
140
+ ) {
141
+ visited.add(tree[VALUE])
142
+ // Recursively explore the dependencies of the current node
143
+ const dependency = libs.find((x) => x.at(1)[VALUE] === tree[VALUE])
144
+ if (dependency) dfs(dependency.at(-1))
145
+ }
146
+ }
167
147
  dfs(ast)
168
- dfs(libs.filter((x) => visited.has(x.at(1)[VALUE])).map((x) => x.at(-1)))
148
+ // Filter out libraries that are not in the visited set
169
149
  return libs.filter((x) => visited.has(x.at(1)[VALUE]))
170
150
  }
151
+
171
152
  export const runFromCompiled = (source) => {
172
153
  const tree = parse(
173
154
  handleUnbalancedQuotes(handleUnbalancedParens(removeNoCode(source)))
package/lib/src/std.lisp DELETED
@@ -1,275 +0,0 @@
1
- (let E 2.718281828459045)
2
- (let PI 3.141592653589793)
3
-
4
- (let* iteration (lambda array callback
5
- (when (length array)
6
- (do (callback (car array))
7
- (iteration (cdr array) callback)))))
8
-
9
- (let scan (lambda array callback (do
10
- (let* iterate (lambda array out
11
- (if (length array)
12
- (iterate (cdr array)
13
- (merge out (Array (callback (car array)))))
14
- out)))
15
- (iterate array ()))))
16
-
17
- (let select (lambda array callback (do
18
- (let* iterate (lambda array out
19
- (if (length array)
20
- (iterate (cdr array)
21
- (if (callback (car array))
22
- (merge out (Array (car array)))
23
- out))
24
- out)))
25
- (iterate array ()))))
26
-
27
- (let exclude (lambda array callback (do
28
- (let* iterate (lambda array out
29
- (if (length array)
30
- (iterate (cdr array)
31
- (if (not (callback (car array)))
32
- (merge out (Array (car array)))
33
- out))
34
- out)))
35
- (iterate array ()))))
36
-
37
- (let fold (lambda array callback initial (do
38
- (let* iterate (lambda array out
39
- (if (length array)
40
- (iterate (cdr array) (callback out (car array)))
41
- out)))
42
- (iterate array initial))))
43
-
44
- (let every? (lambda array callback (do
45
- (let* iterate (lambda array
46
- (if (and (length array) (callback (car array)))
47
- (iterate (cdr array))
48
- (not (length array)))))
49
- (iterate array))))
50
-
51
- (let some? (lambda array callback (do
52
- (let* iterate (lambda array
53
- (if (and (length array) (not (callback (car array))))
54
- (iterate (cdr array))
55
- (type (length array) Boolean))))
56
- (iterate array))))
57
-
58
- (let find (lambda array callback (do
59
- (let* iterate (lambda array
60
- (when (length array)
61
- (if (callback (car array)) (car array) (iterate (cdr array))))))
62
- (iterate array))))
63
-
64
- (let has? (lambda array callback (do
65
- (let* iterate (lambda array
66
- (when (length array)
67
- (if (callback (car array)) 1 (iterate (cdr array))))))
68
- (iterate array))))
69
-
70
- (let reverse (lambda array (do
71
- (let* iterate (lambda array out
72
- (if (length array)
73
- (iterate (cdr array)
74
- (merge (Array (car array)) out))
75
- out)))
76
- (iterate array ()))))
77
-
78
- (let range (lambda start end (do
79
- (let* iterate (lambda out count
80
- (if (<= count end) (iterate (merge out (Array count)) (+ count 1)) out)))
81
- (iterate () start))))
82
-
83
- (let sequence (lambda array (do
84
- (let end (length array))
85
- (let* iterate (lambda out count
86
- (if (< (length out) end) (iterate (merge out (Array count)) (+ count 1)) out)))
87
- (iterate () 0))))
88
-
89
- (let sequence-n (lambda n (do
90
- (let* iterate (lambda out count
91
- (if (< (length out) n) (iterate (merge out (Array count)) (+ count 1)) out)))
92
- (iterate () 0))))
93
-
94
- (let unique (lambda array (go
95
- (let sorted (sort array (safety lambda a b (> a b))))
96
- (zip (sequence sorted))
97
- (select (lambda x
98
- (or (not (let index (car (cdr x))))
99
- (not (= (get sorted (- index 1)) (get sorted index))))))
100
- (scan car))))
101
-
102
- (let for-range (lambda start end callback (do
103
- (let* iterate (lambda i
104
- (when (< i end)
105
- (do
106
- (callback i)
107
- (iterate (+ i 1))))))
108
- (iterate start))))
109
-
110
- (let list-range (lambda start end (do
111
- (let range (lambda list start end
112
- (if (< start end)
113
- (Array (merge list (range (Array (Array (+ start 1))) (+ start 1) end)))
114
- list)))
115
- (car (car (range () start end))))))
116
-
117
- (let traverse (lambda x callback
118
- (if (Atom? x)
119
- (callback x)
120
- (iterate x (lambda y (traverse y callback))))))
121
-
122
- (let summation (lambda array (fold array (safety lambda a b (+ a b)) 0)))
123
- (let product (lambda array (fold array (safety lambda a b (* a b)) 1)))
124
- (let maximum (lambda array (fold array (safety lambda a b (if (> a b) a b)) (car array))))
125
- (let minimum (lambda array (fold array (safety lambda a b (if (< a b) a b)) (car array))))
126
- (let max (lambda a b (if (> a b) a b)))
127
- (let min (lambda a b (if (< a b) a b)))
128
- (let count-of (lambda array callback (go array (select callback) (length))))
129
- (let increment (safety lambda i (+ i 1)))
130
- (let floor (safety lambda n (| n 0)))
131
- (let round (safety lambda n (| (+ n 0.5) 0)))
132
- (let empty? (safety lambda array (not (length array))))
133
- (let array-in-bounds? (safety lambda array index (and (< index (length array)) (>= index 0))))
134
-
135
- (let string->array (safety lambda string (type string Array)))
136
- (let array->string (lambda array (fold array (safety lambda a x (concatenate a (type x String))) "")))
137
- (let string->number (safety lambda string (type string Number)))
138
- (let number->string (safety lambda number (type number String)))
139
- (let strings->numbers (lambda array (scan array (safety lambda x (type x Number)))))
140
- (let numbers->strings (lambda array (scan array (safety lambda x (type x String)))))
141
- (let string->charcodes (lambda string (go string (type Array) (scan (lambda x (type x Char-Code))))))
142
- (let chars->charcodes (lambda array (go array (scan (lambda x (type x Char-Code))))))
143
- (let charcodes->chars (lambda array (go array (scan (lambda x (type x Char))))))
144
- (let charcodes->string (lambda array (go array (scan (lambda x (type x Char))) (array->string))))
145
-
146
- (let power (lambda base exp
147
- (if (< exp 0)
148
- (if (= base 0)
149
- (throw "Attempting to divide by 0 in (power)")
150
- (/ (* base (power base (- (* exp -1) 1)))))
151
- (cond
152
- (= exp 0) 1
153
- (= exp 1) base
154
- (*) (* base (power base (- exp 1)))))))
155
-
156
- (let greatest-common-divisor (lambda a b (do
157
- (let* gcd (lambda a b
158
- (if (= b 0) a (gcd b (mod a b)))) (gcd a b)))))
159
-
160
- (let least-common-divisor (lambda a b (* a b (/ (greatest-common-divisor a b)))))
161
-
162
- (let sqrt (lambda x (do
163
- (let is-good-enough (lambda g x (< (abs (- (square g) x)) 0.01))
164
- improve-guess (lambda g x (average g (* x (/ g)))))
165
- (let* sqrt-iter (lambda g x
166
- (if (is-good-enough g x) g
167
- (sqrt-iter (improve-guess g x) x))))
168
- (sqrt-iter 1.0 x))))
169
- (let circumference (lambda radius (* PI (* radius 2))))
170
- (let hypotenuse (lambda a b (sqrt (+ (* a a) (* b b)))))
171
- (let abs (safety lambda n (- (^ n (>> n 31)) (>> n 31))))
172
- (let nth-digit (lambda digit n (| (mod (/ digit (power 10 (- n 1))) 10) 0.5)))
173
- (let normalize (safety lambda value min max (* (- value min) (/ (- max min)))))
174
- (let linear-interpolation (safety lambda a b n (+ (* (- 1 n) a) (* n b))))
175
- (let gauss-sum (safety lambda n (* n (+ n 1) 0.5)))
176
- (let gauss-sum-sequance (safety lambda a b (* (+ a b) (+ (- b a) 1) 0.5)))
177
- (let clamp (safety lambda x limit (if (> x limit) limit x)))
178
- (let odd? (safety lambda x (= (mod x 2) 1)))
179
- (let even? (safety lambda x (= (mod x 2) 0)))
180
- (let sign (safety lambda n (if (< n 0) -1 1)))
181
- (let radians (lambda deg (* deg PI (/ 180))))
182
- (let average (safety lambda x y (* (+ x y) 0.5)))
183
- (let euclidean-mod (safety lambda a b (mod (+ (mod a b) b) b)))
184
- (let euclidean-distance (lambda x1 y1 x2 y2 (do
185
- (let a (- x1 x2))
186
- (let b (- y1 y2))
187
- (sqrt (+ (* a a) (* b b))))))
188
- (let manhattan-distance (lambda x1 y1 x2 y2 (+ (abs (- x2 x1)) (abs (- y2 y1)))))
189
- (let positive? (safety lambda num (> num 0)))
190
- (let negative? (safety lambda num (< num 0)))
191
- (let zero? (safety lambda num (= num 0)))
192
- (let divisible? (safety lambda a b (= (mod a b) 0)))
193
- (let prime? (lambda n
194
- (cond
195
- (= n 1) 0
196
- (< n 0) 0
197
- (*) (do
198
- (let* iter (lambda i end (do
199
- (let it-is (not (= (mod n i) 0)))
200
- (if (and (<= i end) it-is) (iter (+ i 1) end) it-is))))
201
- (or (= n 2) (iter 2 (sqrt n)))))))
202
-
203
- (let slice (safety lambda array start end (do
204
- (let bounds (- end start))
205
- (let* iterate (lambda i out
206
- (if (< i bounds)
207
- (iterate (+ i 1) (merge out (Array (get array (+ start i)))))
208
- out)))
209
- (iterate 0 ()))))
210
-
211
- (let binary-search
212
- (lambda array target (do
213
- (let* search
214
- (lambda arr target start end (do
215
- (when (<= start end) (do
216
- (let index (floor (* (+ start end) 0.5)))
217
- (let current (get arr index))
218
- (if (= target current) target
219
- (if (> current target)
220
- (search arr target start (- index 1))
221
- (search arr target (+ index 1) end))))))))
222
- (search array target 0 (length array)))))
223
-
224
- (let zip (safety lambda A B (do
225
- (let* iterate (lambda a b output
226
- (if (and (length a) (length b)) (iterate (cdr a) (cdr b) (merge output (Array (Array (car a) (car b))))) output)))
227
- (iterate A B ()))))
228
-
229
- (let cartesian-product (lambda a b (fold a (lambda p x (merge p (scan b (lambda y (Array x y))))) ())))
230
-
231
- (let equal? (lambda a b
232
- (or (and (Atom? a) (Atom? b) (= a b))
233
- (and (Array? a)
234
- (= (length a) (length b))
235
- (not (some? (sequence a) (lambda i (not (equal? (get a i) (get b i))))))))))
236
-
237
- (let split (lambda string delim (do
238
- (let input (type (concatenate string delim) Array))
239
- (let marks
240
- (go
241
- input
242
- (zip (sequence input))
243
- (scan (lambda x (if (= (car x) delim) (car (cdr x)) (car x))))))
244
- (let first (find marks (lambda x (Number? x))))
245
- (go
246
- marks
247
- (fold (lambda a b
248
- (if (Number? b)
249
- (merge a (Array (slice input (- b first) b)))
250
- a)) ())
251
- (scan (lambda x (array->string x)))))))
252
-
253
- (let join (lambda array delim (fold (zip array (sequence array)) (lambda a b (if (> (car (cdr b)) 0) (concatenate a delim (type (car b) String)) (type (car b) String))) "")))
254
-
255
- (let flat (lambda array (do
256
- (let flatten (lambda item
257
- (if (and (Array? item) (length item))
258
- (fold item (lambda a b (merge a (flatten b))) ())
259
- (Array item))))
260
- (flatten array))))
261
-
262
- (let sort (lambda arr callback (do
263
- (if (<= (length arr) 1) arr (do
264
- (let pivot (car arr))
265
- (let* iterate (lambda i bounds a b (do
266
- (let current (get arr i))
267
- (let predicate (callback current pivot))
268
- (let left (if (= predicate 0) (merge a (Array current)) a))
269
- (let right (if (= predicate 1) (merge b (Array current)) b))
270
- (if (< i bounds) (iterate (+ i 1) bounds left right)
271
- (Array left right)))))
272
- (let sorted (iterate 1 (- (length arr) 1) () ()))
273
- (let left (car sorted))
274
- (let right (car (cdr sorted)))
275
- (merge (sort left callback) (Array pivot) (sort right callback)))))))