shen-ruby 0.14.0 → 0.15.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -1
- data/HISTORY.md +6 -3
- data/README.md +10 -7
- data/bin/shen-ruby +21 -0
- data/bin/shen_ruby +21 -0
- data/lib/shen_ruby/converters.rb +2 -4
- data/lib/shen_ruby/shen.rb +1 -1
- data/lib/shen_ruby/version.rb +1 -1
- data/shen/release/klambda/core.kl +67 -63
- data/shen/release/klambda/declarations.kl +92 -84
- data/shen/release/klambda/load.kl +15 -15
- data/shen/release/klambda/macros.kl +34 -33
- data/shen/release/klambda/prolog.kl +96 -98
- data/shen/release/klambda/reader.kl +83 -83
- data/shen/release/klambda/sequent.kl +55 -55
- data/shen/release/klambda/sys.kl +106 -101
- data/shen/release/klambda/t-star.kl +41 -41
- data/shen/release/klambda/toplevel.kl +21 -21
- data/shen/release/klambda/track.kl +25 -25
- data/shen/release/klambda/types.kl +6 -4
- data/shen/release/klambda/writer.kl +25 -25
- data/shen/release/klambda/yacc.kl +28 -28
- data/shen-ruby.gemspec +3 -3
- metadata +9 -5
data/shen/release/klambda/sys.kl
CHANGED
@@ -23,214 +23,214 @@ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
23
23
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
24
24
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
|
25
25
|
|
26
|
-
(defun thaw (
|
26
|
+
(defun thaw (V17359) (V17359))
|
27
27
|
|
28
|
-
(defun eval (
|
28
|
+
(defun eval (V17361) (let Macroexpand (shen.walk (lambda Y (macroexpand Y)) V17361) (if (shen.packaged? Macroexpand) (map (lambda Z (shen.eval-without-macros Z)) (shen.package-contents Macroexpand)) (shen.eval-without-macros Macroexpand))))
|
29
29
|
|
30
|
-
(defun shen.eval-without-macros (
|
30
|
+
(defun shen.eval-without-macros (V17363) (eval-kl (shen.elim-def (shen.proc-input+ V17363))))
|
31
31
|
|
32
|
-
(defun shen.proc-input+ (
|
32
|
+
(defun shen.proc-input+ (V17365) (cond ((and (cons? V17365) (and (= input+ (hd V17365)) (and (cons? (tl V17365)) (and (cons? (tl (tl V17365))) (= () (tl (tl (tl V17365)))))))) (cons input+ (cons (shen.rcons_form (hd (tl V17365))) (tl (tl V17365))))) ((and (cons? V17365) (and (= shen.read+ (hd V17365)) (and (cons? (tl V17365)) (and (cons? (tl (tl V17365))) (= () (tl (tl (tl V17365)))))))) (cons shen.read+ (cons (shen.rcons_form (hd (tl V17365))) (tl (tl V17365))))) ((cons? V17365) (map (lambda Z (shen.proc-input+ Z)) V17365)) (true V17365)))
|
33
33
|
|
34
|
-
(defun shen.elim-def (
|
34
|
+
(defun shen.elim-def (V17367) (cond ((and (cons? V17367) (and (= define (hd V17367)) (cons? (tl V17367)))) (shen.shen->kl (hd (tl V17367)) (tl (tl V17367)))) ((and (cons? V17367) (and (= defmacro (hd V17367)) (cons? (tl V17367)))) (let Default (cons X (cons -> (cons X ()))) (let Def (shen.elim-def (cons define (cons (hd (tl V17367)) (append (tl (tl V17367)) Default)))) (let MacroAdd (shen.add-macro (hd (tl V17367))) Def)))) ((and (cons? V17367) (and (= defcc (hd V17367)) (cons? (tl V17367)))) (shen.elim-def (shen.yacc V17367))) ((cons? V17367) (map (lambda Z (shen.elim-def Z)) V17367)) (true V17367)))
|
35
35
|
|
36
|
-
(defun shen.add-macro (
|
36
|
+
(defun shen.add-macro (V17369) (let MacroReg (value shen.*macroreg*) (let NewMacroReg (set shen.*macroreg* (adjoin V17369 (value shen.*macroreg*))) (if (= MacroReg NewMacroReg) shen.skip (set *macros* (cons (function V17369) (value *macros*)))))))
|
37
37
|
|
38
|
-
(defun shen.packaged? (
|
38
|
+
(defun shen.packaged? (V17377) (cond ((and (cons? V17377) (and (= package (hd V17377)) (and (cons? (tl V17377)) (cons? (tl (tl V17377)))))) true) (true false)))
|
39
39
|
|
40
|
-
(defun external (
|
40
|
+
(defun external (V17379) (trap-error (get V17379 shen.external-symbols (value *property-vector*)) (lambda E (simple-error (cn "package " (shen.app V17379 " has not been used.
|
41
41
|
" shen.a))))))
|
42
42
|
|
43
|
-
(defun shen.package-contents (
|
43
|
+
(defun shen.package-contents (V17383) (cond ((and (cons? V17383) (and (= package (hd V17383)) (and (cons? (tl V17383)) (and (= null (hd (tl V17383))) (cons? (tl (tl V17383))))))) (tl (tl (tl V17383)))) ((and (cons? V17383) (and (= package (hd V17383)) (and (cons? (tl V17383)) (cons? (tl (tl V17383)))))) (shen.packageh (hd (tl V17383)) (hd (tl (tl V17383))) (tl (tl (tl V17383))))) (true (shen.f_error shen.package-contents))))
|
44
44
|
|
45
|
-
(defun shen.walk (
|
45
|
+
(defun shen.walk (V17386 V17387) (cond ((cons? V17387) (V17386 (map (lambda Z (shen.walk V17386 Z)) V17387))) (true (V17386 V17387))))
|
46
46
|
|
47
|
-
(defun compile (
|
47
|
+
(defun compile (V17391 V17392 V17393) (let O (V17391 (cons V17392 (cons () ()))) (if (or (= (fail) O) (not (empty? (hd O)))) (V17393 O) (shen.hdtl O))))
|
48
48
|
|
49
|
-
(defun fail-if (
|
49
|
+
(defun fail-if (V17396 V17397) (if (V17396 V17397) (fail) V17397))
|
50
50
|
|
51
|
-
(defun @s (
|
51
|
+
(defun @s (V17400 V17401) (cn V17400 V17401))
|
52
52
|
|
53
53
|
(defun tc? () (value shen.*tc*))
|
54
54
|
|
55
|
-
(defun ps (
|
55
|
+
(defun ps (V17403) (trap-error (get V17403 shen.source (value *property-vector*)) (lambda E (simple-error (shen.app V17403 " not found.
|
56
56
|
" shen.a)))))
|
57
57
|
|
58
58
|
(defun stinput () (value *stinput*))
|
59
59
|
|
60
|
-
(defun shen.+vector? (
|
60
|
+
(defun shen.+vector? (V17405) (and (absvector? V17405) (> (<-address V17405 0) 0)))
|
61
61
|
|
62
|
-
(defun vector (
|
62
|
+
(defun vector (V17407) (let Vector (absvector (+ V17407 1)) (let ZeroStamp (address-> Vector 0 V17407) (let Standard (if (= V17407 0) ZeroStamp (shen.fillvector ZeroStamp 1 V17407 (fail))) Standard))))
|
63
63
|
|
64
|
-
(defun shen.fillvector (
|
64
|
+
(defun shen.fillvector (V17413 V17414 V17415 V17416) (cond ((= V17415 V17414) (address-> V17413 V17415 V17416)) (true (shen.fillvector (address-> V17413 V17414 V17416) (+ 1 V17414) V17415 V17416))))
|
65
65
|
|
66
|
-
(defun vector? (
|
66
|
+
(defun vector? (V17418) (and (absvector? V17418) (trap-error (>= (<-address V17418 0) 0) (lambda E false))))
|
67
67
|
|
68
|
-
(defun vector-> (
|
69
|
-
") (address->
|
68
|
+
(defun vector-> (V17422 V17423 V17424) (if (= V17423 0) (simple-error "cannot access 0th element of a vector
|
69
|
+
") (address-> V17422 V17423 V17424)))
|
70
70
|
|
71
|
-
(defun <-vector (
|
72
|
-
") (let VectorElement (<-address
|
71
|
+
(defun <-vector (V17427 V17428) (if (= V17428 0) (simple-error "cannot access 0th element of a vector
|
72
|
+
") (let VectorElement (<-address V17427 V17428) (if (= VectorElement (fail)) (simple-error "vector element not found
|
73
73
|
") VectorElement))))
|
74
74
|
|
75
|
-
(defun shen.posint? (
|
75
|
+
(defun shen.posint? (V17430) (and (integer? V17430) (>= V17430 0)))
|
76
76
|
|
77
|
-
(defun limit (
|
77
|
+
(defun limit (V17432) (<-address V17432 0))
|
78
78
|
|
79
|
-
(defun symbol? (
|
79
|
+
(defun symbol? (V17434) (cond ((or (boolean? V17434) (or (number? V17434) (string? V17434))) false) (true (trap-error (let String (str V17434) (shen.analyse-symbol? String)) (lambda E false)))))
|
80
80
|
|
81
|
-
(defun shen.analyse-symbol? (
|
81
|
+
(defun shen.analyse-symbol? (V17436) (cond ((shen.+string? V17436) (and (shen.alpha? (pos V17436 0)) (shen.alphanums? (tlstr V17436)))) (true (shen.f_error shen.analyse-symbol?))))
|
82
82
|
|
83
|
-
(defun shen.alpha? (
|
83
|
+
(defun shen.alpha? (V17438) (element? V17438 (cons "A" (cons "B" (cons "C" (cons "D" (cons "E" (cons "F" (cons "G" (cons "H" (cons "I" (cons "J" (cons "K" (cons "L" (cons "M" (cons "N" (cons "O" (cons "P" (cons "Q" (cons "R" (cons "S" (cons "T" (cons "U" (cons "V" (cons "W" (cons "X" (cons "Y" (cons "Z" (cons "a" (cons "b" (cons "c" (cons "d" (cons "e" (cons "f" (cons "g" (cons "h" (cons "i" (cons "j" (cons "k" (cons "l" (cons "m" (cons "n" (cons "o" (cons "p" (cons "q" (cons "r" (cons "s" (cons "t" (cons "u" (cons "v" (cons "w" (cons "x" (cons "y" (cons "z" (cons "=" (cons "*" (cons "/" (cons "+" (cons "-" (cons "_" (cons "?" (cons "$" (cons "!" (cons "@" (cons "~" (cons ">" (cons "<" (cons "&" (cons "%" (cons "{" (cons "}" (cons ":" (cons ";" (cons "`" (cons "#" (cons "'" (cons "." ())))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
|
84
84
|
|
85
|
-
(defun shen.alphanums? (
|
85
|
+
(defun shen.alphanums? (V17440) (cond ((= "" V17440) true) ((shen.+string? V17440) (and (shen.alphanum? (pos V17440 0)) (shen.alphanums? (tlstr V17440)))) (true (shen.f_error shen.alphanums?))))
|
86
86
|
|
87
|
-
(defun shen.alphanum? (
|
87
|
+
(defun shen.alphanum? (V17442) (or (shen.alpha? V17442) (shen.digit? V17442)))
|
88
88
|
|
89
|
-
(defun shen.digit? (
|
89
|
+
(defun shen.digit? (V17444) (element? V17444 (cons "1" (cons "2" (cons "3" (cons "4" (cons "5" (cons "6" (cons "7" (cons "8" (cons "9" (cons "0" ()))))))))))))
|
90
90
|
|
91
|
-
(defun variable? (
|
91
|
+
(defun variable? (V17446) (cond ((or (boolean? V17446) (or (number? V17446) (string? V17446))) false) (true (trap-error (let String (str V17446) (shen.analyse-variable? String)) (lambda E false)))))
|
92
92
|
|
93
|
-
(defun shen.analyse-variable? (
|
93
|
+
(defun shen.analyse-variable? (V17448) (cond ((shen.+string? V17448) (and (shen.uppercase? (pos V17448 0)) (shen.alphanums? (tlstr V17448)))) (true (shen.f_error shen.analyse-variable?))))
|
94
94
|
|
95
|
-
(defun shen.uppercase? (
|
95
|
+
(defun shen.uppercase? (V17450) (element? V17450 (cons "A" (cons "B" (cons "C" (cons "D" (cons "E" (cons "F" (cons "G" (cons "H" (cons "I" (cons "J" (cons "K" (cons "L" (cons "M" (cons "N" (cons "O" (cons "P" (cons "Q" (cons "R" (cons "S" (cons "T" (cons "U" (cons "V" (cons "W" (cons "X" (cons "Y" (cons "Z" ()))))))))))))))))))))))))))))
|
96
96
|
|
97
|
-
(defun gensym (
|
97
|
+
(defun gensym (V17452) (concat V17452 (set shen.*gensym* (+ 1 (value shen.*gensym*)))))
|
98
98
|
|
99
|
-
(defun concat (
|
99
|
+
(defun concat (V17455 V17456) (intern (cn (str V17455) (str V17456))))
|
100
100
|
|
101
|
-
(defun @p (
|
101
|
+
(defun @p (V17459 V17460) (let Vector (absvector 3) (let Tag (address-> Vector 0 shen.tuple) (let Fst (address-> Vector 1 V17459) (let Snd (address-> Vector 2 V17460) Vector)))))
|
102
102
|
|
103
|
-
(defun fst (
|
103
|
+
(defun fst (V17462) (<-address V17462 1))
|
104
104
|
|
105
|
-
(defun snd (
|
105
|
+
(defun snd (V17464) (<-address V17464 2))
|
106
106
|
|
107
|
-
(defun tuple? (
|
107
|
+
(defun tuple? (V17466) (trap-error (and (absvector? V17466) (= shen.tuple (<-address V17466 0))) (lambda E false)))
|
108
108
|
|
109
|
-
(defun append (
|
109
|
+
(defun append (V17469 V17470) (cond ((= () V17469) V17470) ((cons? V17469) (cons (hd V17469) (append (tl V17469) V17470))) (true (shen.f_error append))))
|
110
110
|
|
111
|
-
(defun @v (
|
111
|
+
(defun @v (V17473 V17474) (let Limit (limit V17474) (let NewVector (vector (+ Limit 1)) (let X+NewVector (vector-> NewVector 1 V17473) (if (= Limit 0) X+NewVector (shen.@v-help V17474 1 Limit X+NewVector))))))
|
112
112
|
|
113
|
-
(defun shen.@v-help (
|
113
|
+
(defun shen.@v-help (V17480 V17481 V17482 V17483) (cond ((= V17482 V17481) (shen.copyfromvector V17480 V17483 V17482 (+ V17482 1))) (true (shen.@v-help V17480 (+ V17481 1) V17482 (shen.copyfromvector V17480 V17483 V17481 (+ V17481 1))))))
|
114
114
|
|
115
|
-
(defun shen.copyfromvector (
|
115
|
+
(defun shen.copyfromvector (V17488 V17489 V17490 V17491) (trap-error (vector-> V17489 V17491 (<-vector V17488 V17490)) (lambda E V17489)))
|
116
116
|
|
117
|
-
(defun hdv (
|
117
|
+
(defun hdv (V17493) (trap-error (<-vector V17493 1) (lambda E (simple-error (cn "hdv needs a non-empty vector as an argument; not " (shen.app V17493 "
|
118
118
|
" shen.s))))))
|
119
119
|
|
120
|
-
(defun tlv (
|
121
|
-
") (if (= Limit 1) (vector 0) (let NewVector (vector (- Limit 1)) (shen.tlv-help
|
120
|
+
(defun tlv (V17495) (let Limit (limit V17495) (if (= Limit 0) (simple-error "cannot take the tail of the empty vector
|
121
|
+
") (if (= Limit 1) (vector 0) (let NewVector (vector (- Limit 1)) (shen.tlv-help V17495 2 Limit (vector (- Limit 1))))))))
|
122
122
|
|
123
|
-
(defun shen.tlv-help (
|
123
|
+
(defun shen.tlv-help (V17501 V17502 V17503 V17504) (cond ((= V17503 V17502) (shen.copyfromvector V17501 V17504 V17503 (- V17503 1))) (true (shen.tlv-help V17501 (+ V17502 1) V17503 (shen.copyfromvector V17501 V17504 V17502 (- V17502 1))))))
|
124
124
|
|
125
|
-
(defun assoc (
|
125
|
+
(defun assoc (V17516 V17517) (cond ((= () V17517) ()) ((and (cons? V17517) (and (cons? (hd V17517)) (= (hd (hd V17517)) V17516))) (hd V17517)) ((cons? V17517) (assoc V17516 (tl V17517))) (true (shen.f_error assoc))))
|
126
126
|
|
127
|
-
(defun boolean? (
|
127
|
+
(defun boolean? (V17523) (cond ((= true V17523) true) ((= false V17523) true) (true false)))
|
128
128
|
|
129
|
-
(defun nl (
|
130
|
-
" (stoutput)) (nl (-
|
129
|
+
(defun nl (V17525) (cond ((= 0 V17525) 0) (true (do (shen.prhush "
|
130
|
+
" (stoutput)) (nl (- V17525 1))))))
|
131
131
|
|
132
|
-
(defun difference (
|
132
|
+
(defun difference (V17530 V17531) (cond ((= () V17530) ()) ((cons? V17530) (if (element? (hd V17530) V17531) (difference (tl V17530) V17531) (cons (hd V17530) (difference (tl V17530) V17531)))) (true (shen.f_error difference))))
|
133
133
|
|
134
|
-
(defun do (
|
134
|
+
(defun do (V17534 V17535) V17535)
|
135
135
|
|
136
|
-
(defun element? (
|
136
|
+
(defun element? (V17547 V17548) (cond ((= () V17548) false) ((and (cons? V17548) (= (hd V17548) V17547)) true) ((cons? V17548) (element? V17547 (tl V17548))) (true (shen.f_error element?))))
|
137
137
|
|
138
|
-
(defun empty? (
|
138
|
+
(defun empty? (V17554) (cond ((= () V17554) true) (true false)))
|
139
139
|
|
140
|
-
(defun fix (
|
140
|
+
(defun fix (V17557 V17558) (shen.fix-help V17557 V17558 (V17557 V17558)))
|
141
141
|
|
142
|
-
(defun shen.fix-help (
|
142
|
+
(defun shen.fix-help (V17569 V17570 V17571) (cond ((= V17571 V17570) V17571) (true (shen.fix-help V17569 V17571 (V17569 V17571)))))
|
143
143
|
|
144
|
-
(defun put (
|
144
|
+
(defun put (V17576 V17577 V17578 V17579) (let N (hash V17576 (limit V17579)) (let Entry (trap-error (<-vector V17579 N) (lambda E ())) (let Change (vector-> V17579 N (shen.change-pointer-value V17576 V17577 V17578 Entry)) V17578))))
|
145
145
|
|
146
|
-
(defun unput (
|
146
|
+
(defun unput (V17583 V17584 V17585) (let N (hash V17583 (limit V17585)) (let Entry (trap-error (<-vector V17585 N) (lambda E ())) (let Change (vector-> V17585 N (shen.remove-pointer V17583 V17584 Entry)) V17583))))
|
147
147
|
|
148
|
-
(defun shen.remove-pointer (
|
148
|
+
(defun shen.remove-pointer (V17593 V17594 V17595) (cond ((= () V17595) ()) ((and (cons? V17595) (and (cons? (hd V17595)) (and (cons? (hd (hd V17595))) (and (cons? (tl (hd (hd V17595)))) (and (= () (tl (tl (hd (hd V17595))))) (and (= (hd (tl (hd (hd V17595)))) V17594) (= (hd (hd (hd V17595))) V17593))))))) (tl V17595)) ((cons? V17595) (cons (hd V17595) (shen.remove-pointer V17593 V17594 (tl V17595)))) (true (shen.f_error shen.remove-pointer))))
|
149
149
|
|
150
|
-
(defun shen.change-pointer-value (
|
150
|
+
(defun shen.change-pointer-value (V17604 V17605 V17606 V17607) (cond ((= () V17607) (cons (cons (cons V17604 (cons V17605 ())) V17606) ())) ((and (cons? V17607) (and (cons? (hd V17607)) (and (cons? (hd (hd V17607))) (and (cons? (tl (hd (hd V17607)))) (and (= () (tl (tl (hd (hd V17607))))) (and (= (hd (tl (hd (hd V17607)))) V17605) (= (hd (hd (hd V17607))) V17604))))))) (cons (cons (hd (hd V17607)) V17606) (tl V17607))) ((cons? V17607) (cons (hd V17607) (shen.change-pointer-value V17604 V17605 V17606 (tl V17607)))) (true (shen.f_error shen.change-pointer-value))))
|
151
151
|
|
152
|
-
(defun get (
|
153
|
-
"))) (let Result (assoc (cons
|
152
|
+
(defun get (V17611 V17612 V17613) (let N (hash V17611 (limit V17613)) (let Entry (trap-error (<-vector V17613 N) (lambda E (simple-error "pointer not found
|
153
|
+
"))) (let Result (assoc (cons V17611 (cons V17612 ())) Entry) (if (empty? Result) (simple-error "value not found
|
154
154
|
") (tl Result))))))
|
155
155
|
|
156
|
-
(defun hash (
|
156
|
+
(defun hash (V17616 V17617) (let Hash (shen.mod (sum (map (lambda X (string->n X)) (explode V17616))) V17617) (if (= 0 Hash) 1 Hash)))
|
157
157
|
|
158
|
-
(defun shen.mod (
|
158
|
+
(defun shen.mod (V17620 V17621) (shen.modh V17620 (shen.multiples V17620 (cons V17621 ()))))
|
159
159
|
|
160
|
-
(defun shen.multiples (
|
160
|
+
(defun shen.multiples (V17624 V17625) (cond ((and (cons? V17625) (> (hd V17625) V17624)) (tl V17625)) ((cons? V17625) (shen.multiples V17624 (cons (* 2 (hd V17625)) V17625))) (true (shen.f_error shen.multiples))))
|
161
161
|
|
162
|
-
(defun shen.modh (
|
162
|
+
(defun shen.modh (V17630 V17631) (cond ((= 0 V17630) 0) ((= () V17631) V17630) ((and (cons? V17631) (> (hd V17631) V17630)) (if (empty? (tl V17631)) V17630 (shen.modh V17630 (tl V17631)))) ((cons? V17631) (shen.modh (- V17630 (hd V17631)) V17631)) (true (shen.f_error shen.modh))))
|
163
163
|
|
164
|
-
(defun sum (
|
164
|
+
(defun sum (V17633) (cond ((= () V17633) 0) ((cons? V17633) (+ (hd V17633) (sum (tl V17633)))) (true (shen.f_error sum))))
|
165
165
|
|
166
|
-
(defun head (
|
166
|
+
(defun head (V17641) (cond ((cons? V17641) (hd V17641)) (true (simple-error "head expects a non-empty list"))))
|
167
167
|
|
168
|
-
(defun tail (
|
168
|
+
(defun tail (V17649) (cond ((cons? V17649) (tl V17649)) (true (simple-error "tail expects a non-empty list"))))
|
169
169
|
|
170
|
-
(defun hdstr (
|
170
|
+
(defun hdstr (V17651) (pos V17651 0))
|
171
171
|
|
172
|
-
(defun intersection (
|
172
|
+
(defun intersection (V17656 V17657) (cond ((= () V17656) ()) ((cons? V17656) (if (element? (hd V17656) V17657) (cons (hd V17656) (intersection (tl V17656) V17657)) (intersection (tl V17656) V17657))) (true (shen.f_error intersection))))
|
173
173
|
|
174
|
-
(defun reverse (
|
174
|
+
(defun reverse (V17659) (shen.reverse_help V17659 ()))
|
175
175
|
|
176
|
-
(defun shen.reverse_help (
|
176
|
+
(defun shen.reverse_help (V17662 V17663) (cond ((= () V17662) V17663) ((cons? V17662) (shen.reverse_help (tl V17662) (cons (hd V17662) V17663))) (true (shen.f_error shen.reverse_help))))
|
177
177
|
|
178
|
-
(defun union (
|
178
|
+
(defun union (V17666 V17667) (cond ((= () V17666) V17667) ((cons? V17666) (if (element? (hd V17666) V17667) (union (tl V17666) V17667) (cons (hd V17666) (union (tl V17666) V17667)))) (true (shen.f_error union))))
|
179
179
|
|
180
|
-
(defun y-or-n? (
|
181
|
-
" (stoutput)) (y-or-n?
|
180
|
+
(defun y-or-n? (V17669) (let Message (shen.prhush (shen.proc-nl V17669) (stoutput)) (let Y-or-N (shen.prhush " (y/n) " (stoutput)) (let Input (shen.app (read (stinput)) "" shen.s) (if (= "y" Input) true (if (= "n" Input) false (do (shen.prhush "please answer y or n
|
181
|
+
" (stoutput)) (y-or-n? V17669))))))))
|
182
182
|
|
183
|
-
(defun not (
|
183
|
+
(defun not (V17671) (if V17671 false true))
|
184
184
|
|
185
|
-
(defun subst (
|
185
|
+
(defun subst (V17684 V17685 V17686) (cond ((= V17686 V17685) V17684) ((cons? V17686) (map (lambda W (subst V17684 V17685 W)) V17686)) (true V17686)))
|
186
186
|
|
187
|
-
(defun explode (
|
187
|
+
(defun explode (V17688) (shen.explode-h (shen.app V17688 "" shen.a)))
|
188
188
|
|
189
|
-
(defun shen.explode-h (
|
189
|
+
(defun shen.explode-h (V17690) (cond ((= "" V17690) ()) ((shen.+string? V17690) (cons (pos V17690 0) (shen.explode-h (tlstr V17690)))) (true (shen.f_error shen.explode-h))))
|
190
190
|
|
191
|
-
(defun cd (
|
191
|
+
(defun cd (V17692) (set *home-directory* (if (= V17692 "") "" (shen.app V17692 "/" shen.a))))
|
192
192
|
|
193
|
-
(defun map (
|
193
|
+
(defun map (V17695 V17696) (shen.map-h V17695 V17696 ()))
|
194
194
|
|
195
|
-
(defun shen.map-h (
|
195
|
+
(defun shen.map-h (V17702 V17703 V17704) (cond ((= () V17703) (reverse V17704)) ((cons? V17703) (shen.map-h V17702 (tl V17703) (cons (V17702 (hd V17703)) V17704))) (true (shen.f_error shen.map-h))))
|
196
196
|
|
197
|
-
(defun length (
|
197
|
+
(defun length (V17706) (shen.length-h V17706 0))
|
198
198
|
|
199
|
-
(defun shen.length-h (
|
199
|
+
(defun shen.length-h (V17709 V17710) (cond ((= () V17709) V17710) (true (shen.length-h (tl V17709) (+ V17710 1)))))
|
200
200
|
|
201
|
-
(defun occurrences (
|
201
|
+
(defun occurrences (V17722 V17723) (cond ((= V17723 V17722) 1) ((cons? V17723) (+ (occurrences V17722 (hd V17723)) (occurrences V17722 (tl V17723)))) (true 0)))
|
202
202
|
|
203
|
-
(defun nth (
|
203
|
+
(defun nth (V17732 V17733) (cond ((and (= 1 V17732) (cons? V17733)) (hd V17733)) ((cons? V17733) (nth (- V17732 1) (tl V17733))) (true (shen.f_error nth))))
|
204
204
|
|
205
|
-
(defun integer? (
|
205
|
+
(defun integer? (V17735) (and (number? V17735) (let Abs (shen.abs V17735) (shen.integer-test? Abs (shen.magless Abs 1)))))
|
206
206
|
|
207
|
-
(defun shen.abs (
|
207
|
+
(defun shen.abs (V17737) (if (> V17737 0) V17737 (- 0 V17737)))
|
208
208
|
|
209
|
-
(defun shen.magless (
|
209
|
+
(defun shen.magless (V17740 V17741) (let Nx2 (* V17741 2) (if (> Nx2 V17740) V17741 (shen.magless V17740 Nx2))))
|
210
210
|
|
211
|
-
(defun shen.integer-test? (
|
211
|
+
(defun shen.integer-test? (V17747 V17748) (cond ((= 0 V17747) true) ((> 1 V17747) false) (true (let Abs-N (- V17747 V17748) (if (> 0 Abs-N) (integer? V17747) (shen.integer-test? Abs-N V17748))))))
|
212
212
|
|
213
|
-
(defun mapcan (
|
213
|
+
(defun mapcan (V17753 V17754) (cond ((= () V17754) ()) ((cons? V17754) (append (V17753 (hd V17754)) (mapcan V17753 (tl V17754)))) (true (shen.f_error mapcan))))
|
214
214
|
|
215
|
-
(defun == (
|
215
|
+
(defun == (V17766 V17767) (cond ((= V17767 V17766) true) (true false)))
|
216
216
|
|
217
217
|
(defun abort () (simple-error ""))
|
218
218
|
|
219
|
-
(defun bound? (
|
219
|
+
(defun bound? (V17769) (and (symbol? V17769) (let Val (trap-error (value V17769) (lambda E shen.this-symbol-is-unbound)) (if (= Val shen.this-symbol-is-unbound) false true))))
|
220
220
|
|
221
|
-
(defun shen.string->bytes (
|
221
|
+
(defun shen.string->bytes (V17771) (cond ((= "" V17771) ()) (true (cons (string->n (pos V17771 0)) (shen.string->bytes (tlstr V17771))))))
|
222
222
|
|
223
|
-
(defun maxinferences (
|
223
|
+
(defun maxinferences (V17773) (set shen.*maxinferences* V17773))
|
224
224
|
|
225
225
|
(defun inferences () (value shen.*infs*))
|
226
226
|
|
227
|
-
(defun protect (
|
227
|
+
(defun protect (V17775) V17775)
|
228
228
|
|
229
229
|
(defun stoutput () (value *stoutput*))
|
230
230
|
|
231
|
-
(defun string->symbol (
|
231
|
+
(defun string->symbol (V17777) (let Symbol (intern V17777) (if (symbol? Symbol) Symbol (simple-error (cn "cannot intern " (shen.app V17777 " to a symbol" shen.s))))))
|
232
232
|
|
233
|
-
(defun optimise (
|
233
|
+
(defun optimise (V17783) (cond ((= + V17783) (set shen.*optimise* true)) ((= - V17783) (set shen.*optimise* false)) (true (simple-error "optimise expects a + or a -.
|
234
234
|
"))))
|
235
235
|
|
236
236
|
(defun os () (value *os*))
|
@@ -247,7 +247,12 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
|
|
247
247
|
|
248
248
|
(defun release () (value *release*))
|
249
249
|
|
250
|
-
(defun package? (
|
250
|
+
(defun package? (V17785) (trap-error (do (external V17785) true) (lambda E false)))
|
251
|
+
|
252
|
+
(defun function (V17787) (shen.lookup-func V17787 (value shen.*symbol-table*)))
|
253
|
+
|
254
|
+
(defun shen.lookup-func (V17797 V17798) (cond ((= () V17798) (simple-error (shen.app V17797 " has no lambda expansion
|
255
|
+
" shen.a))) ((and (cons? V17798) (and (cons? (hd V17798)) (= (hd (hd V17798)) V17797))) (tl (hd V17798))) ((cons? V17798) (shen.lookup-func V17797 (tl V17798))) (true (shen.f_error shen.lookup-func))))
|
251
256
|
|
252
257
|
|
253
258
|
|