shen-ruby 0.10.0 → 0.11.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (128) hide show
  1. checksums.yaml +4 -4
  2. data/.rspec +1 -0
  3. data/.travis.yml +9 -3
  4. data/Gemfile +1 -4
  5. data/HISTORY.md +16 -0
  6. data/MIT_LICENSE.txt +1 -1
  7. data/README.md +25 -26
  8. data/Rakefile +3 -11
  9. data/bin/shen_test_suite.rb +15 -3
  10. data/bin/srrepl +6 -8
  11. data/lib/shen_ruby.rb +6 -1
  12. data/lib/shen_ruby/converters.rb +23 -0
  13. data/lib/shen_ruby/version.rb +1 -1
  14. data/shen-ruby.gemspec +4 -1
  15. data/shen/lib/shen_ruby/shen.rb +49 -33
  16. data/shen/release/benchmarks/N_queens.shen +45 -45
  17. data/shen/release/benchmarks/README.shen +14 -14
  18. data/shen/release/benchmarks/benchmarks.shen +52 -52
  19. data/shen/release/benchmarks/einstein.shen +32 -32
  20. data/shen/release/benchmarks/interpreter.shen +219 -219
  21. data/shen/release/benchmarks/jnk.shen +193 -193
  22. data/shen/release/benchmarks/powerset.shen +10 -10
  23. data/shen/release/benchmarks/prime.shen +10 -10
  24. data/shen/release/benchmarks/short.shen +129 -129
  25. data/shen/release/k_lambda/core.kl +181 -181
  26. data/shen/release/k_lambda/declarations.kl +131 -131
  27. data/shen/release/k_lambda/load.kl +84 -84
  28. data/shen/release/k_lambda/macros.kl +112 -112
  29. data/shen/release/k_lambda/prolog.kl +252 -252
  30. data/shen/release/k_lambda/reader.kl +222 -222
  31. data/shen/release/k_lambda/sequent.kl +166 -166
  32. data/shen/release/k_lambda/sys.kl +271 -271
  33. data/shen/release/k_lambda/t-star.kl +139 -139
  34. data/shen/release/k_lambda/toplevel.kl +135 -135
  35. data/shen/release/k_lambda/track.kl +103 -103
  36. data/shen/release/k_lambda/types.kl +324 -324
  37. data/shen/release/k_lambda/writer.kl +105 -105
  38. data/shen/release/k_lambda/yacc.kl +113 -113
  39. data/shen/release/test_programs/Chap13/problems.txt +26 -26
  40. data/shen/release/test_programs/README.shen +52 -52
  41. data/shen/release/test_programs/TinyLispFunctions.txt +15 -15
  42. data/shen/release/test_programs/TinyTypes.shen +55 -55
  43. data/shen/release/test_programs/binary.shen +24 -24
  44. data/shen/release/test_programs/bubble_version_1.shen +28 -28
  45. data/shen/release/test_programs/bubble_version_2.shen +22 -22
  46. data/shen/release/test_programs/calculator.shen +21 -21
  47. data/shen/release/test_programs/cartprod.shen +23 -23
  48. data/shen/release/test_programs/change.shen +25 -25
  49. data/shen/release/test_programs/classes-defaults.shen +94 -94
  50. data/shen/release/test_programs/classes-inheritance.shen +100 -100
  51. data/shen/release/test_programs/classes-typed.shen +74 -74
  52. data/shen/release/test_programs/classes-untyped.shen +46 -46
  53. data/shen/release/test_programs/depth_.shen +14 -14
  54. data/shen/release/test_programs/einstein.shen +34 -34
  55. data/shen/release/test_programs/fruit_machine.shen +46 -46
  56. data/shen/release/test_programs/interpreter.shen +217 -217
  57. data/shen/release/test_programs/metaprog.shen +85 -85
  58. data/shen/release/test_programs/minim.shen +192 -192
  59. data/shen/release/test_programs/mutual.shen +11 -11
  60. data/shen/release/test_programs/n_queens.shen +45 -45
  61. data/shen/release/test_programs/newton_version_1.shen +33 -33
  62. data/shen/release/test_programs/newton_version_2.shen +24 -24
  63. data/shen/release/test_programs/parse.prl +14 -14
  64. data/shen/release/test_programs/parser.shen +51 -51
  65. data/shen/release/test_programs/powerset.shen +10 -10
  66. data/shen/release/test_programs/prime.shen +10 -10
  67. data/shen/release/test_programs/prolog.shen +78 -78
  68. data/shen/release/test_programs/proof_assistant.shen +80 -80
  69. data/shen/release/test_programs/proplog_version_1.shen +25 -25
  70. data/shen/release/test_programs/proplog_version_2.shen +27 -27
  71. data/shen/release/test_programs/qmachine.shen +66 -66
  72. data/shen/release/test_programs/red-black.shen +54 -54
  73. data/shen/release/test_programs/search.shen +55 -55
  74. data/shen/release/test_programs/semantic_net.shen +44 -44
  75. data/shen/release/test_programs/spreadsheet.shen +34 -34
  76. data/shen/release/test_programs/stack.shen +27 -27
  77. data/shen/release/test_programs/streams.shen +20 -20
  78. data/shen/release/test_programs/strings.shen +57 -57
  79. data/shen/release/test_programs/structures-typed.shen +71 -71
  80. data/shen/release/test_programs/structures-untyped.shen +41 -41
  81. data/shen/release/test_programs/tests.shen +232 -232
  82. data/shen/release/test_programs/types.shen +11 -11
  83. data/shen/release/test_programs/whist.shen +239 -239
  84. data/shen/release/test_programs/yacc.shen +132 -132
  85. data/spec/shen_ruby/converters_spec.rb +48 -0
  86. data/spec/spec_helper.rb +1 -2
  87. metadata +55 -60
  88. data/k_lambda_spec/atom_spec.rb +0 -85
  89. data/k_lambda_spec/primitives/arithmetic_spec.rb +0 -175
  90. data/k_lambda_spec/primitives/assignments_spec.rb +0 -44
  91. data/k_lambda_spec/primitives/boolean_operations_spec.rb +0 -136
  92. data/k_lambda_spec/primitives/generic_functions_spec.rb +0 -120
  93. data/k_lambda_spec/primitives/lists_spec.rb +0 -40
  94. data/k_lambda_spec/primitives/strings_spec.rb +0 -77
  95. data/k_lambda_spec/primitives/symbols_spec.rb +0 -24
  96. data/k_lambda_spec/primitives/vectors_spec.rb +0 -92
  97. data/k_lambda_spec/spec_helper.rb +0 -29
  98. data/k_lambda_spec/support/shared_examples.rb +0 -124
  99. data/k_lambda_spec/tail_recursion_spec.rb +0 -30
  100. data/lib/kl.rb +0 -7
  101. data/lib/kl/absvector.rb +0 -12
  102. data/lib/kl/compiler.rb +0 -360
  103. data/lib/kl/cons.rb +0 -51
  104. data/lib/kl/empty_list.rb +0 -12
  105. data/lib/kl/environment.rb +0 -163
  106. data/lib/kl/error.rb +0 -4
  107. data/lib/kl/internal_error.rb +0 -7
  108. data/lib/kl/lexer.rb +0 -186
  109. data/lib/kl/primitives/arithmetic.rb +0 -60
  110. data/lib/kl/primitives/assignments.rb +0 -15
  111. data/lib/kl/primitives/booleans.rb +0 -21
  112. data/lib/kl/primitives/error_handling.rb +0 -13
  113. data/lib/kl/primitives/extensions.rb +0 -12
  114. data/lib/kl/primitives/generic_functions.rb +0 -29
  115. data/lib/kl/primitives/lists.rb +0 -23
  116. data/lib/kl/primitives/streams.rb +0 -28
  117. data/lib/kl/primitives/strings.rb +0 -63
  118. data/lib/kl/primitives/symbols.rb +0 -18
  119. data/lib/kl/primitives/time.rb +0 -17
  120. data/lib/kl/primitives/vectors.rb +0 -36
  121. data/lib/kl/reader.rb +0 -46
  122. data/spec/kl/cons_spec.rb +0 -12
  123. data/spec/kl/environment_spec.rb +0 -282
  124. data/spec/kl/interop_spec.rb +0 -68
  125. data/spec/kl/lexer_spec.rb +0 -149
  126. data/spec/kl/primitives/generic_functions_spec.rb +0 -29
  127. data/spec/kl/primitives/symbols_spec.rb +0 -21
  128. data/spec/kl/reader_spec.rb +0 -42
@@ -1,271 +1,271 @@
1
- "**********************************************************************************
2
- * The License *
3
- * *
4
- * The user is free to produce commercial applications with the software, to *
5
- * distribute these applications in source or binary form, and to charge monies *
6
- * for them as he sees fit and in concordance with the laws of the land subject *
7
- * to the following license. *
8
- * *
9
- * 1. The license applies to all the software and all derived software and *
10
- * must appear on such. *
11
- * *
12
- * 2. It is illegal to distribute the software without this license attached *
13
- * to it and use of the software implies agreement with the license as such. *
14
- * It is illegal for anyone who is not the copyright holder to tamper with *
15
- * or change the license. *
16
- * *
17
- * 3. Neither the names of Lambda Associates or the copyright holder may be used *
18
- * to endorse or promote products built using the software without specific *
19
- * prior written permission from the copyright holder. *
20
- * *
21
- * 4. That possession of this license does not confer on the copyright holder *
22
- * any special contractual obligation towards the user. That in no event *
23
- * shall the copyright holder be liable for any direct, indirect, incidental, *
24
- * special, exemplary or consequential damages (including but not limited *
25
- * to procurement of substitute goods or services, loss of use, data, *
26
- * interruption), however caused and on any theory of liability, whether in *
27
- * contract, strict liability or tort (including negligence) arising in any *
28
- * way out of the use of the software, even if advised of the possibility of *
29
- * such damage. *
30
- * *
31
- * 5. It is permitted for the user to change the software, for the purpose of *
32
- * improving performance, correcting an error, or porting to a new platform, *
33
- * and distribute the derived version of Shen provided the resulting program *
34
- * conforms in all respects to the Shen standard and is issued under that *
35
- * title. The user must make it clear with his distribution that he/she is *
36
- * the author of the changes and what these changes are and why. *
37
- * *
38
- * 6. Derived versions of this software in whatever form are subject to the same *
39
- * restrictions. In particular it is not permitted to make derived copies of *
40
- * this software which do not conform to the Shen standard or appear under a *
41
- * different title. *
42
- * *
43
- * It is permitted to distribute versions of Shen which incorporate libraries, *
44
- * graphics or other facilities which are not part of the Shen standard. *
45
- * *
46
- * For an explication of this license see www.shenlanguage.org/license.htm which *
47
- * explains this license in full. *
48
- * *
49
- *****************************************************************************************
50
- "(defun thaw (V1862) (V1862))
51
-
52
- (defun eval (V1863) (let Macroexpand (shen.walk (lambda X1857 (macroexpand X1857)) V1863) (if (shen.packaged? Macroexpand) (map (lambda X1858 (shen.eval-without-macros X1858)) (shen.package-contents Macroexpand)) (shen.eval-without-macros Macroexpand))))
53
-
54
- (defun shen.eval-without-macros (V1864) (eval-kl (shen.elim-def (shen.proc-input+ V1864))))
55
-
56
- (defun shen.proc-input+ (V1865) (cond ((and (cons? V1865) (and (= input+ (hd V1865)) (and (cons? (tl V1865)) (and (cons? (tl (tl V1865))) (= () (tl (tl (tl V1865)))))))) (cons input+ (cons (shen.rcons_form (hd (tl V1865))) (tl (tl V1865))))) ((and (cons? V1865) (and (= read+ (hd V1865)) (and (cons? (tl V1865)) (and (cons? (tl (tl V1865))) (= () (tl (tl (tl V1865)))))))) (cons read+ (cons (shen.rcons_form (hd (tl V1865))) (tl (tl V1865))))) ((cons? V1865) (map (lambda X1859 (shen.proc-input+ X1859)) V1865)) (true V1865)))
57
-
58
- (defun shen.elim-def (V1866) (cond ((and (cons? V1866) (and (= define (hd V1866)) (cons? (tl V1866)))) (shen.shen->kl (hd (tl V1866)) (tl (tl V1866)))) ((and (cons? V1866) (and (= defmacro (hd V1866)) (cons? (tl V1866)))) (let Default (cons X (cons -> (cons X ()))) (let Def (shen.elim-def (cons define (cons (hd (tl V1866)) (append (tl (tl V1866)) Default)))) (let MacroAdd (shen.add-macro (hd (tl V1866))) Def)))) ((and (cons? V1866) (and (= defcc (hd V1866)) (cons? (tl V1866)))) (shen.elim-def (shen.yacc V1866))) ((cons? V1866) (map (lambda X1860 (shen.elim-def X1860)) V1866)) (true V1866)))
59
-
60
- (defun shen.add-macro (V1867) (set *macros* (adjoin V1867 (value *macros*))))
61
-
62
- (defun shen.packaged? (V1874) (cond ((and (cons? V1874) (and (= package (hd V1874)) (and (cons? (tl V1874)) (cons? (tl (tl V1874)))))) true) (true false)))
63
-
64
- (defun external (V1875) (trap-error (get V1875 shen.external-symbols (value *property-vector*)) (lambda E (simple-error (cn "package " (shen.app V1875 " has not been used.
65
- " shen.a))))))
66
-
67
- (defun shen.package-contents (V1878) (cond ((and (cons? V1878) (and (= package (hd V1878)) (and (cons? (tl V1878)) (and (= null (hd (tl V1878))) (cons? (tl (tl V1878))))))) (tl (tl (tl V1878)))) ((and (cons? V1878) (and (= package (hd V1878)) (and (cons? (tl V1878)) (cons? (tl (tl V1878)))))) (shen.packageh (hd (tl V1878)) (hd (tl (tl V1878))) (tl (tl (tl V1878))))) (true (shen.sys-error shen.package-contents))))
68
-
69
- (defun shen.walk (V1879 V1880) (cond ((cons? V1880) (V1879 (map (lambda Z (shen.walk V1879 Z)) V1880))) (true (V1879 V1880))))
70
-
71
- (defun compile (V1881 V1882 V1883) (let O (V1881 (cons V1882 (cons () ()))) (if (or (= (fail) O) (not (empty? (hd O)))) (V1883 O) (shen.hdtl O))))
72
-
73
- (defun fail-if (V1884 V1885) (if (V1884 V1885) (fail) V1885))
74
-
75
- (defun @s (V1886 V1887) (cn V1886 V1887))
76
-
77
- (defun tc? () (value shen.*tc*))
78
-
79
- (defun ps (V1888) (trap-error (get V1888 shen.source (value *property-vector*)) (lambda E (simple-error (shen.app V1888 " not found.
80
- " shen.a)))))
81
-
82
- (defun stinput () (value *stinput*))
83
-
84
- (defun shen.+vector? (V1889) (and (absvector? V1889) (> (<-address V1889 0) 0)))
85
-
86
- (defun vector (V1890) (let Vector (absvector (+ V1890 1)) (let ZeroStamp (address-> Vector 0 V1890) (let Standard (if (= V1890 0) ZeroStamp (shen.fillvector ZeroStamp 1 V1890 (fail))) Standard))))
87
-
88
- (defun shen.fillvector (V1891 V1892 V1893 V1894) (cond ((= V1893 V1892) (address-> V1891 V1893 V1894)) (true (shen.fillvector (address-> V1891 V1892 V1894) (+ 1 V1892) V1893 V1894))))
89
-
90
- (defun vector? (V1896) (and (absvector? V1896) (trap-error (>= (<-address V1896 0) 0) (lambda E false))))
91
-
92
- (defun vector-> (V1897 V1898 V1899) (if (= V1898 0) (simple-error "cannot access 0th element of a vector
93
- ") (address-> V1897 V1898 V1899)))
94
-
95
- (defun <-vector (V1900 V1901) (if (= V1901 0) (simple-error "cannot access 0th element of a vector
96
- ") (let VectorElement (<-address V1900 V1901) (if (= VectorElement (fail)) (simple-error "vector element not found
97
- ") VectorElement))))
98
-
99
- (defun shen.posint? (V1902) (and (integer? V1902) (>= V1902 0)))
100
-
101
- (defun limit (V1903) (<-address V1903 0))
102
-
103
- (defun symbol? (V1904) (cond ((or (boolean? V1904) (or (number? V1904) (string? V1904))) false) (true (trap-error (let String (str V1904) (shen.analyse-symbol? String)) (lambda E false)))))
104
-
105
- (defun shen.analyse-symbol? (V1905) (cond ((shen.+string? V1905) (and (shen.alpha? (pos V1905 0)) (shen.alphanums? (tlstr V1905)))) (true (shen.sys-error shen.analyse-symbol?))))
106
-
107
- (defun shen.alpha? (V1906) (element? V1906 (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 "." ())))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
108
-
109
- (defun shen.alphanums? (V1907) (cond ((= "" V1907) true) ((shen.+string? V1907) (and (shen.alphanum? (pos V1907 0)) (shen.alphanums? (tlstr V1907)))) (true (shen.sys-error shen.alphanums?))))
110
-
111
- (defun shen.alphanum? (V1908) (or (shen.alpha? V1908) (shen.digit? V1908)))
112
-
113
- (defun shen.digit? (V1909) (element? V1909 (cons "1" (cons "2" (cons "3" (cons "4" (cons "5" (cons "6" (cons "7" (cons "8" (cons "9" (cons "0" ()))))))))))))
114
-
115
- (defun variable? (V1910) (cond ((or (boolean? V1910) (or (number? V1910) (string? V1910))) false) (true (trap-error (let String (str V1910) (shen.analyse-variable? String)) (lambda E false)))))
116
-
117
- (defun shen.analyse-variable? (V1911) (cond ((shen.+string? V1911) (and (shen.uppercase? (pos V1911 0)) (shen.alphanums? (tlstr V1911)))) (true (shen.sys-error shen.analyse-variable?))))
118
-
119
- (defun shen.uppercase? (V1912) (element? V1912 (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" ()))))))))))))))))))))))))))))
120
-
121
- (defun gensym (V1913) (concat V1913 (set shen.*gensym* (+ 1 (value shen.*gensym*)))))
122
-
123
- (defun concat (V1914 V1915) (intern (cn (str V1914) (str V1915))))
124
-
125
- (defun @p (V1916 V1917) (let Vector (absvector 3) (let Tag (address-> Vector 0 shen.tuple) (let Fst (address-> Vector 1 V1916) (let Snd (address-> Vector 2 V1917) Vector)))))
126
-
127
- (defun fst (V1918) (<-address V1918 1))
128
-
129
- (defun snd (V1919) (<-address V1919 2))
130
-
131
- (defun tuple? (V1920) (trap-error (and (absvector? V1920) (= shen.tuple (<-address V1920 0))) (lambda E false)))
132
-
133
- (defun append (V1921 V1922) (cond ((= () V1921) V1922) ((cons? V1921) (cons (hd V1921) (append (tl V1921) V1922))) (true (shen.sys-error append))))
134
-
135
- (defun @v (V1923 V1924) (let Limit (limit V1924) (let NewVector (vector (+ Limit 1)) (let X+NewVector (vector-> NewVector 1 V1923) (if (= Limit 0) X+NewVector (shen.@v-help V1924 1 Limit X+NewVector))))))
136
-
137
- (defun shen.@v-help (V1925 V1926 V1927 V1928) (cond ((= V1927 V1926) (shen.copyfromvector V1925 V1928 V1927 (+ V1927 1))) (true (shen.@v-help V1925 (+ V1926 1) V1927 (shen.copyfromvector V1925 V1928 V1926 (+ V1926 1))))))
138
-
139
- (defun shen.copyfromvector (V1930 V1931 V1932 V1933) (trap-error (vector-> V1931 V1933 (<-vector V1930 V1932)) (lambda E V1931)))
140
-
141
- (defun hdv (V1934) (trap-error (<-vector V1934 1) (lambda E (simple-error (cn "hdv needs a non-empty vector as an argument; not " (shen.app V1934 "
142
- " shen.s))))))
143
-
144
- (defun tlv (V1935) (let Limit (limit V1935) (if (= Limit 0) (simple-error "cannot take the tail of the empty vector
145
- ") (if (= Limit 1) (vector 0) (let NewVector (vector (- Limit 1)) (shen.tlv-help V1935 2 Limit (vector (- Limit 1))))))))
146
-
147
- (defun shen.tlv-help (V1936 V1937 V1938 V1939) (cond ((= V1938 V1937) (shen.copyfromvector V1936 V1939 V1938 (- V1938 1))) (true (shen.tlv-help V1936 (+ V1937 1) V1938 (shen.copyfromvector V1936 V1939 V1937 (- V1937 1))))))
148
-
149
- (defun assoc (V1949 V1950) (cond ((= () V1950) ()) ((and (cons? V1950) (and (cons? (hd V1950)) (= (hd (hd V1950)) V1949))) (hd V1950)) ((cons? V1950) (assoc V1949 (tl V1950))) (true (shen.sys-error assoc))))
150
-
151
- (defun boolean? (V1956) (cond ((= true V1956) true) ((= false V1956) true) (true false)))
152
-
153
- (defun nl (V1957) (cond ((= 0 V1957) 0) (true (do (shen.prhush "
154
- " (stoutput)) (nl (- V1957 1))))))
155
-
156
- (defun difference (V1960 V1961) (cond ((= () V1960) ()) ((cons? V1960) (if (element? (hd V1960) V1961) (difference (tl V1960) V1961) (cons (hd V1960) (difference (tl V1960) V1961)))) (true (shen.sys-error difference))))
157
-
158
- (defun do (V1962 V1963) V1963)
159
-
160
- (defun element? (V1972 V1973) (cond ((= () V1973) false) ((and (cons? V1973) (= (hd V1973) V1972)) true) ((cons? V1973) (element? V1972 (tl V1973))) (true (shen.sys-error element?))))
161
-
162
- (defun empty? (V1979) (cond ((= () V1979) true) (true false)))
163
-
164
- (defun fix (V1980 V1981) (shen.fix-help V1980 V1981 (V1980 V1981)))
165
-
166
- (defun shen.fix-help (V1988 V1989 V1990) (cond ((= V1990 V1989) V1990) (true (shen.fix-help V1988 V1990 (V1988 V1990)))))
167
-
168
- (defun put (V1992 V1993 V1994 V1995) (let N (hash V1992 (limit V1995)) (let Entry (trap-error (<-vector V1995 N) (lambda E ())) (let Change (vector-> V1995 N (shen.change-pointer-value V1992 V1993 V1994 Entry)) V1994))))
169
-
170
- (defun shen.change-pointer-value (V1998 V1999 V2000 V2001) (cond ((= () V2001) (cons (cons (cons V1998 (cons V1999 ())) V2000) ())) ((and (cons? V2001) (and (cons? (hd V2001)) (and (cons? (hd (hd V2001))) (and (cons? (tl (hd (hd V2001)))) (and (= () (tl (tl (hd (hd V2001))))) (and (= (hd (tl (hd (hd V2001)))) V1999) (= (hd (hd (hd V2001))) V1998))))))) (cons (cons (hd (hd V2001)) V2000) (tl V2001))) ((cons? V2001) (cons (hd V2001) (shen.change-pointer-value V1998 V1999 V2000 (tl V2001)))) (true (shen.sys-error shen.change-pointer-value))))
171
-
172
- (defun get (V2004 V2005 V2006) (let N (hash V2004 (limit V2006)) (let Entry (trap-error (<-vector V2006 N) (lambda E (simple-error "pointer not found
173
- "))) (let Result (assoc (cons V2004 (cons V2005 ())) Entry) (if (empty? Result) (simple-error "value not found
174
- ") (tl Result))))))
175
-
176
- (defun hash (V2007 V2008) (let Hash (shen.mod (sum (map (lambda X1861 (string->n X1861)) (explode V2007))) V2008) (if (= 0 Hash) 1 Hash)))
177
-
178
- (defun shen.mod (V2009 V2010) (shen.modh V2009 (shen.multiples V2009 (cons V2010 ()))))
179
-
180
- (defun shen.multiples (V2011 V2012) (cond ((and (cons? V2012) (> (hd V2012) V2011)) (tl V2012)) ((cons? V2012) (shen.multiples V2011 (cons (* 2 (hd V2012)) V2012))) (true (shen.sys-error shen.multiples))))
181
-
182
- (defun shen.modh (V2015 V2016) (cond ((= 0 V2015) 0) ((= () V2016) V2015) ((and (cons? V2016) (> (hd V2016) V2015)) (if (empty? (tl V2016)) V2015 (shen.modh V2015 (tl V2016)))) ((cons? V2016) (shen.modh (- V2015 (hd V2016)) V2016)) (true (shen.sys-error shen.modh))))
183
-
184
- (defun sum (V2017) (cond ((= () V2017) 0) ((cons? V2017) (+ (hd V2017) (sum (tl V2017)))) (true (shen.sys-error sum))))
185
-
186
- (defun head (V2024) (cond ((cons? V2024) (hd V2024)) (true (simple-error "head expects a non-empty list"))))
187
-
188
- (defun tail (V2031) (cond ((cons? V2031) (tl V2031)) (true (simple-error "tail expects a non-empty list"))))
189
-
190
- (defun hdstr (V2032) (pos V2032 0))
191
-
192
- (defun intersection (V2035 V2036) (cond ((= () V2035) ()) ((cons? V2035) (if (element? (hd V2035) V2036) (cons (hd V2035) (intersection (tl V2035) V2036)) (intersection (tl V2035) V2036))) (true (shen.sys-error intersection))))
193
-
194
- (defun reverse (V2037) (shen.reverse_help V2037 ()))
195
-
196
- (defun shen.reverse_help (V2038 V2039) (cond ((= () V2038) V2039) ((cons? V2038) (shen.reverse_help (tl V2038) (cons (hd V2038) V2039))) (true (shen.sys-error shen.reverse_help))))
197
-
198
- (defun union (V2040 V2041) (cond ((= () V2040) V2041) ((cons? V2040) (if (element? (hd V2040) V2041) (union (tl V2040) V2041) (cons (hd V2040) (union (tl V2040) V2041)))) (true (shen.sys-error union))))
199
-
200
- (defun y-or-n? (V2042) (let Message (shen.prhush (shen.proc-nl V2042) (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
201
- " (stoutput)) (y-or-n? V2042))))))))
202
-
203
- (defun not (V2043) (if V2043 false true))
204
-
205
- (defun subst (V2052 V2053 V2054) (cond ((= V2054 V2053) V2052) ((cons? V2054) (map (lambda W (subst V2052 V2053 W)) V2054)) (true V2054)))
206
-
207
- (defun explode (V2056) (shen.explode-h (shen.app V2056 "" shen.a)))
208
-
209
- (defun shen.explode-h (V2057) (cond ((= "" V2057) ()) ((shen.+string? V2057) (cons (pos V2057 0) (shen.explode-h (tlstr V2057)))) (true (shen.sys-error shen.explode-h))))
210
-
211
- (defun cd (V2058) (set *home-directory* (if (= V2058 "") "" (shen.app V2058 "/" shen.a))))
212
-
213
- (defun map (V2059 V2060) (shen.map-h V2059 V2060 ()))
214
-
215
- (defun shen.map-h (V2063 V2064 V2065) (cond ((= () V2064) (reverse V2065)) ((cons? V2064) (shen.map-h V2063 (tl V2064) (cons (V2063 (hd V2064)) V2065))) (true (shen.sys-error shen.map-h))))
216
-
217
- (defun length (V2066) (shen.length-h V2066 0))
218
-
219
- (defun shen.length-h (V2067 V2068) (cond ((= () V2067) V2068) (true (shen.length-h (tl V2067) (+ V2068 1)))))
220
-
221
- (defun occurrences (V2077 V2078) (cond ((= V2078 V2077) 1) ((cons? V2078) (+ (occurrences V2077 (hd V2078)) (occurrences V2077 (tl V2078)))) (true 0)))
222
-
223
- (defun nth (V2086 V2087) (cond ((and (= 1 V2086) (cons? V2087)) (hd V2087)) ((cons? V2087) (nth (- V2086 1) (tl V2087))) (true (shen.sys-error nth))))
224
-
225
- (defun integer? (V2088) (and (number? V2088) (let Abs (shen.abs V2088) (shen.integer-test? Abs (shen.magless Abs 1)))))
226
-
227
- (defun shen.abs (V2089) (if (> V2089 0) V2089 (- 0 V2089)))
228
-
229
- (defun shen.magless (V2090 V2091) (let Nx2 (* V2091 2) (if (> Nx2 V2090) V2091 (shen.magless V2090 Nx2))))
230
-
231
- (defun shen.integer-test? (V2095 V2096) (cond ((= 0 V2095) true) ((> 1 V2095) false) (true (let Abs-N (- V2095 V2096) (if (> 0 Abs-N) (integer? V2095) (shen.integer-test? Abs-N V2096))))))
232
-
233
- (defun mapcan (V2099 V2100) (cond ((= () V2100) ()) ((cons? V2100) (append (V2099 (hd V2100)) (mapcan V2099 (tl V2100)))) (true (shen.sys-error mapcan))))
234
-
235
- (defun == (V2109 V2110) (cond ((= V2110 V2109) true) (true false)))
236
-
237
- (defun abort () (simple-error ""))
238
-
239
- (defun bound? (V2112) (and (symbol? V2112) (let Val (trap-error (value V2112) (lambda E shen.this-symbol-is-unbound)) (if (= Val shen.this-symbol-is-unbound) false true))))
240
-
241
- (defun shen.string->bytes (V2113) (cond ((= "" V2113) ()) (true (cons (string->n (pos V2113 0)) (shen.string->bytes (tlstr V2113))))))
242
-
243
- (defun maxinferences (V2114) (set shen.*maxinferences* V2114))
244
-
245
- (defun inferences () (value shen.*infs*))
246
-
247
- (defun protect (V2115) V2115)
248
-
249
- (defun stoutput () (value *stoutput*))
250
-
251
- (defun string->symbol (V2116) (let Symbol (intern V2116) (if (symbol? Symbol) Symbol (simple-error (cn "cannot intern " (shen.app V2116 " to a symbol" shen.s))))))
252
-
253
- (defun shen.optimise (V2121) (cond ((= + V2121) (set shen.*optimise* true)) ((= - V2121) (set shen.*optimise* false)) (true (simple-error "optimise expects a + or a -.
254
- "))))
255
-
256
- (defun os () (value *os*))
257
-
258
- (defun language () (value *language*))
259
-
260
- (defun version () (value *version*))
261
-
262
- (defun port () (value *port*))
263
-
264
- (defun porters () (value *porters*))
265
-
266
- (defun implementation () (value *implementation*))
267
-
268
- (defun release () (value *release*))
269
-
270
-
271
-
1
+ "**********************************************************************************
2
+ * The License *
3
+ * *
4
+ * The user is free to produce commercial applications with the software, to *
5
+ * distribute these applications in source or binary form, and to charge monies *
6
+ * for them as he sees fit and in concordance with the laws of the land subject *
7
+ * to the following license. *
8
+ * *
9
+ * 1. The license applies to all the software and all derived software and *
10
+ * must appear on such. *
11
+ * *
12
+ * 2. It is illegal to distribute the software without this license attached *
13
+ * to it and use of the software implies agreement with the license as such. *
14
+ * It is illegal for anyone who is not the copyright holder to tamper with *
15
+ * or change the license. *
16
+ * *
17
+ * 3. Neither the names of Lambda Associates or the copyright holder may be used *
18
+ * to endorse or promote products built using the software without specific *
19
+ * prior written permission from the copyright holder. *
20
+ * *
21
+ * 4. That possession of this license does not confer on the copyright holder *
22
+ * any special contractual obligation towards the user. That in no event *
23
+ * shall the copyright holder be liable for any direct, indirect, incidental, *
24
+ * special, exemplary or consequential damages (including but not limited *
25
+ * to procurement of substitute goods or services, loss of use, data, *
26
+ * interruption), however caused and on any theory of liability, whether in *
27
+ * contract, strict liability or tort (including negligence) arising in any *
28
+ * way out of the use of the software, even if advised of the possibility of *
29
+ * such damage. *
30
+ * *
31
+ * 5. It is permitted for the user to change the software, for the purpose of *
32
+ * improving performance, correcting an error, or porting to a new platform, *
33
+ * and distribute the derived version of Shen provided the resulting program *
34
+ * conforms in all respects to the Shen standard and is issued under that *
35
+ * title. The user must make it clear with his distribution that he/she is *
36
+ * the author of the changes and what these changes are and why. *
37
+ * *
38
+ * 6. Derived versions of this software in whatever form are subject to the same *
39
+ * restrictions. In particular it is not permitted to make derived copies of *
40
+ * this software which do not conform to the Shen standard or appear under a *
41
+ * different title. *
42
+ * *
43
+ * It is permitted to distribute versions of Shen which incorporate libraries, *
44
+ * graphics or other facilities which are not part of the Shen standard. *
45
+ * *
46
+ * For an explication of this license see www.shenlanguage.org/license.htm which *
47
+ * explains this license in full. *
48
+ * *
49
+ *****************************************************************************************
50
+ "(defun thaw (V1862) (V1862))
51
+
52
+ (defun eval (V1863) (let Macroexpand (shen.walk (lambda X1857 (macroexpand X1857)) V1863) (if (shen.packaged? Macroexpand) (map (lambda X1858 (shen.eval-without-macros X1858)) (shen.package-contents Macroexpand)) (shen.eval-without-macros Macroexpand))))
53
+
54
+ (defun shen.eval-without-macros (V1864) (eval-kl (shen.elim-def (shen.proc-input+ V1864))))
55
+
56
+ (defun shen.proc-input+ (V1865) (cond ((and (cons? V1865) (and (= input+ (hd V1865)) (and (cons? (tl V1865)) (and (cons? (tl (tl V1865))) (= () (tl (tl (tl V1865)))))))) (cons input+ (cons (shen.rcons_form (hd (tl V1865))) (tl (tl V1865))))) ((and (cons? V1865) (and (= read+ (hd V1865)) (and (cons? (tl V1865)) (and (cons? (tl (tl V1865))) (= () (tl (tl (tl V1865)))))))) (cons read+ (cons (shen.rcons_form (hd (tl V1865))) (tl (tl V1865))))) ((cons? V1865) (map (lambda X1859 (shen.proc-input+ X1859)) V1865)) (true V1865)))
57
+
58
+ (defun shen.elim-def (V1866) (cond ((and (cons? V1866) (and (= define (hd V1866)) (cons? (tl V1866)))) (shen.shen->kl (hd (tl V1866)) (tl (tl V1866)))) ((and (cons? V1866) (and (= defmacro (hd V1866)) (cons? (tl V1866)))) (let Default (cons X (cons -> (cons X ()))) (let Def (shen.elim-def (cons define (cons (hd (tl V1866)) (append (tl (tl V1866)) Default)))) (let MacroAdd (shen.add-macro (hd (tl V1866))) Def)))) ((and (cons? V1866) (and (= defcc (hd V1866)) (cons? (tl V1866)))) (shen.elim-def (shen.yacc V1866))) ((cons? V1866) (map (lambda X1860 (shen.elim-def X1860)) V1866)) (true V1866)))
59
+
60
+ (defun shen.add-macro (V1867) (set *macros* (adjoin V1867 (value *macros*))))
61
+
62
+ (defun shen.packaged? (V1874) (cond ((and (cons? V1874) (and (= package (hd V1874)) (and (cons? (tl V1874)) (cons? (tl (tl V1874)))))) true) (true false)))
63
+
64
+ (defun external (V1875) (trap-error (get V1875 shen.external-symbols (value *property-vector*)) (lambda E (simple-error (cn "package " (shen.app V1875 " has not been used.
65
+ " shen.a))))))
66
+
67
+ (defun shen.package-contents (V1878) (cond ((and (cons? V1878) (and (= package (hd V1878)) (and (cons? (tl V1878)) (and (= null (hd (tl V1878))) (cons? (tl (tl V1878))))))) (tl (tl (tl V1878)))) ((and (cons? V1878) (and (= package (hd V1878)) (and (cons? (tl V1878)) (cons? (tl (tl V1878)))))) (shen.packageh (hd (tl V1878)) (hd (tl (tl V1878))) (tl (tl (tl V1878))))) (true (shen.sys-error shen.package-contents))))
68
+
69
+ (defun shen.walk (V1879 V1880) (cond ((cons? V1880) (V1879 (map (lambda Z (shen.walk V1879 Z)) V1880))) (true (V1879 V1880))))
70
+
71
+ (defun compile (V1881 V1882 V1883) (let O (V1881 (cons V1882 (cons () ()))) (if (or (= (fail) O) (not (empty? (hd O)))) (V1883 O) (shen.hdtl O))))
72
+
73
+ (defun fail-if (V1884 V1885) (if (V1884 V1885) (fail) V1885))
74
+
75
+ (defun @s (V1886 V1887) (cn V1886 V1887))
76
+
77
+ (defun tc? () (value shen.*tc*))
78
+
79
+ (defun ps (V1888) (trap-error (get V1888 shen.source (value *property-vector*)) (lambda E (simple-error (shen.app V1888 " not found.
80
+ " shen.a)))))
81
+
82
+ (defun stinput () (value *stinput*))
83
+
84
+ (defun shen.+vector? (V1889) (and (absvector? V1889) (> (<-address V1889 0) 0)))
85
+
86
+ (defun vector (V1890) (let Vector (absvector (+ V1890 1)) (let ZeroStamp (address-> Vector 0 V1890) (let Standard (if (= V1890 0) ZeroStamp (shen.fillvector ZeroStamp 1 V1890 (fail))) Standard))))
87
+
88
+ (defun shen.fillvector (V1891 V1892 V1893 V1894) (cond ((= V1893 V1892) (address-> V1891 V1893 V1894)) (true (shen.fillvector (address-> V1891 V1892 V1894) (+ 1 V1892) V1893 V1894))))
89
+
90
+ (defun vector? (V1896) (and (absvector? V1896) (trap-error (>= (<-address V1896 0) 0) (lambda E false))))
91
+
92
+ (defun vector-> (V1897 V1898 V1899) (if (= V1898 0) (simple-error "cannot access 0th element of a vector
93
+ ") (address-> V1897 V1898 V1899)))
94
+
95
+ (defun <-vector (V1900 V1901) (if (= V1901 0) (simple-error "cannot access 0th element of a vector
96
+ ") (let VectorElement (<-address V1900 V1901) (if (= VectorElement (fail)) (simple-error "vector element not found
97
+ ") VectorElement))))
98
+
99
+ (defun shen.posint? (V1902) (and (integer? V1902) (>= V1902 0)))
100
+
101
+ (defun limit (V1903) (<-address V1903 0))
102
+
103
+ (defun symbol? (V1904) (cond ((or (boolean? V1904) (or (number? V1904) (string? V1904))) false) (true (trap-error (let String (str V1904) (shen.analyse-symbol? String)) (lambda E false)))))
104
+
105
+ (defun shen.analyse-symbol? (V1905) (cond ((shen.+string? V1905) (and (shen.alpha? (pos V1905 0)) (shen.alphanums? (tlstr V1905)))) (true (shen.sys-error shen.analyse-symbol?))))
106
+
107
+ (defun shen.alpha? (V1906) (element? V1906 (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 "." ())))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
108
+
109
+ (defun shen.alphanums? (V1907) (cond ((= "" V1907) true) ((shen.+string? V1907) (and (shen.alphanum? (pos V1907 0)) (shen.alphanums? (tlstr V1907)))) (true (shen.sys-error shen.alphanums?))))
110
+
111
+ (defun shen.alphanum? (V1908) (or (shen.alpha? V1908) (shen.digit? V1908)))
112
+
113
+ (defun shen.digit? (V1909) (element? V1909 (cons "1" (cons "2" (cons "3" (cons "4" (cons "5" (cons "6" (cons "7" (cons "8" (cons "9" (cons "0" ()))))))))))))
114
+
115
+ (defun variable? (V1910) (cond ((or (boolean? V1910) (or (number? V1910) (string? V1910))) false) (true (trap-error (let String (str V1910) (shen.analyse-variable? String)) (lambda E false)))))
116
+
117
+ (defun shen.analyse-variable? (V1911) (cond ((shen.+string? V1911) (and (shen.uppercase? (pos V1911 0)) (shen.alphanums? (tlstr V1911)))) (true (shen.sys-error shen.analyse-variable?))))
118
+
119
+ (defun shen.uppercase? (V1912) (element? V1912 (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" ()))))))))))))))))))))))))))))
120
+
121
+ (defun gensym (V1913) (concat V1913 (set shen.*gensym* (+ 1 (value shen.*gensym*)))))
122
+
123
+ (defun concat (V1914 V1915) (intern (cn (str V1914) (str V1915))))
124
+
125
+ (defun @p (V1916 V1917) (let Vector (absvector 3) (let Tag (address-> Vector 0 shen.tuple) (let Fst (address-> Vector 1 V1916) (let Snd (address-> Vector 2 V1917) Vector)))))
126
+
127
+ (defun fst (V1918) (<-address V1918 1))
128
+
129
+ (defun snd (V1919) (<-address V1919 2))
130
+
131
+ (defun tuple? (V1920) (trap-error (and (absvector? V1920) (= shen.tuple (<-address V1920 0))) (lambda E false)))
132
+
133
+ (defun append (V1921 V1922) (cond ((= () V1921) V1922) ((cons? V1921) (cons (hd V1921) (append (tl V1921) V1922))) (true (shen.sys-error append))))
134
+
135
+ (defun @v (V1923 V1924) (let Limit (limit V1924) (let NewVector (vector (+ Limit 1)) (let X+NewVector (vector-> NewVector 1 V1923) (if (= Limit 0) X+NewVector (shen.@v-help V1924 1 Limit X+NewVector))))))
136
+
137
+ (defun shen.@v-help (V1925 V1926 V1927 V1928) (cond ((= V1927 V1926) (shen.copyfromvector V1925 V1928 V1927 (+ V1927 1))) (true (shen.@v-help V1925 (+ V1926 1) V1927 (shen.copyfromvector V1925 V1928 V1926 (+ V1926 1))))))
138
+
139
+ (defun shen.copyfromvector (V1930 V1931 V1932 V1933) (trap-error (vector-> V1931 V1933 (<-vector V1930 V1932)) (lambda E V1931)))
140
+
141
+ (defun hdv (V1934) (trap-error (<-vector V1934 1) (lambda E (simple-error (cn "hdv needs a non-empty vector as an argument; not " (shen.app V1934 "
142
+ " shen.s))))))
143
+
144
+ (defun tlv (V1935) (let Limit (limit V1935) (if (= Limit 0) (simple-error "cannot take the tail of the empty vector
145
+ ") (if (= Limit 1) (vector 0) (let NewVector (vector (- Limit 1)) (shen.tlv-help V1935 2 Limit (vector (- Limit 1))))))))
146
+
147
+ (defun shen.tlv-help (V1936 V1937 V1938 V1939) (cond ((= V1938 V1937) (shen.copyfromvector V1936 V1939 V1938 (- V1938 1))) (true (shen.tlv-help V1936 (+ V1937 1) V1938 (shen.copyfromvector V1936 V1939 V1937 (- V1937 1))))))
148
+
149
+ (defun assoc (V1949 V1950) (cond ((= () V1950) ()) ((and (cons? V1950) (and (cons? (hd V1950)) (= (hd (hd V1950)) V1949))) (hd V1950)) ((cons? V1950) (assoc V1949 (tl V1950))) (true (shen.sys-error assoc))))
150
+
151
+ (defun boolean? (V1956) (cond ((= true V1956) true) ((= false V1956) true) (true false)))
152
+
153
+ (defun nl (V1957) (cond ((= 0 V1957) 0) (true (do (shen.prhush "
154
+ " (stoutput)) (nl (- V1957 1))))))
155
+
156
+ (defun difference (V1960 V1961) (cond ((= () V1960) ()) ((cons? V1960) (if (element? (hd V1960) V1961) (difference (tl V1960) V1961) (cons (hd V1960) (difference (tl V1960) V1961)))) (true (shen.sys-error difference))))
157
+
158
+ (defun do (V1962 V1963) V1963)
159
+
160
+ (defun element? (V1972 V1973) (cond ((= () V1973) false) ((and (cons? V1973) (= (hd V1973) V1972)) true) ((cons? V1973) (element? V1972 (tl V1973))) (true (shen.sys-error element?))))
161
+
162
+ (defun empty? (V1979) (cond ((= () V1979) true) (true false)))
163
+
164
+ (defun fix (V1980 V1981) (shen.fix-help V1980 V1981 (V1980 V1981)))
165
+
166
+ (defun shen.fix-help (V1988 V1989 V1990) (cond ((= V1990 V1989) V1990) (true (shen.fix-help V1988 V1990 (V1988 V1990)))))
167
+
168
+ (defun put (V1992 V1993 V1994 V1995) (let N (hash V1992 (limit V1995)) (let Entry (trap-error (<-vector V1995 N) (lambda E ())) (let Change (vector-> V1995 N (shen.change-pointer-value V1992 V1993 V1994 Entry)) V1994))))
169
+
170
+ (defun shen.change-pointer-value (V1998 V1999 V2000 V2001) (cond ((= () V2001) (cons (cons (cons V1998 (cons V1999 ())) V2000) ())) ((and (cons? V2001) (and (cons? (hd V2001)) (and (cons? (hd (hd V2001))) (and (cons? (tl (hd (hd V2001)))) (and (= () (tl (tl (hd (hd V2001))))) (and (= (hd (tl (hd (hd V2001)))) V1999) (= (hd (hd (hd V2001))) V1998))))))) (cons (cons (hd (hd V2001)) V2000) (tl V2001))) ((cons? V2001) (cons (hd V2001) (shen.change-pointer-value V1998 V1999 V2000 (tl V2001)))) (true (shen.sys-error shen.change-pointer-value))))
171
+
172
+ (defun get (V2004 V2005 V2006) (let N (hash V2004 (limit V2006)) (let Entry (trap-error (<-vector V2006 N) (lambda E (simple-error "pointer not found
173
+ "))) (let Result (assoc (cons V2004 (cons V2005 ())) Entry) (if (empty? Result) (simple-error "value not found
174
+ ") (tl Result))))))
175
+
176
+ (defun hash (V2007 V2008) (let Hash (shen.mod (sum (map (lambda X1861 (string->n X1861)) (explode V2007))) V2008) (if (= 0 Hash) 1 Hash)))
177
+
178
+ (defun shen.mod (V2009 V2010) (shen.modh V2009 (shen.multiples V2009 (cons V2010 ()))))
179
+
180
+ (defun shen.multiples (V2011 V2012) (cond ((and (cons? V2012) (> (hd V2012) V2011)) (tl V2012)) ((cons? V2012) (shen.multiples V2011 (cons (* 2 (hd V2012)) V2012))) (true (shen.sys-error shen.multiples))))
181
+
182
+ (defun shen.modh (V2015 V2016) (cond ((= 0 V2015) 0) ((= () V2016) V2015) ((and (cons? V2016) (> (hd V2016) V2015)) (if (empty? (tl V2016)) V2015 (shen.modh V2015 (tl V2016)))) ((cons? V2016) (shen.modh (- V2015 (hd V2016)) V2016)) (true (shen.sys-error shen.modh))))
183
+
184
+ (defun sum (V2017) (cond ((= () V2017) 0) ((cons? V2017) (+ (hd V2017) (sum (tl V2017)))) (true (shen.sys-error sum))))
185
+
186
+ (defun head (V2024) (cond ((cons? V2024) (hd V2024)) (true (simple-error "head expects a non-empty list"))))
187
+
188
+ (defun tail (V2031) (cond ((cons? V2031) (tl V2031)) (true (simple-error "tail expects a non-empty list"))))
189
+
190
+ (defun hdstr (V2032) (pos V2032 0))
191
+
192
+ (defun intersection (V2035 V2036) (cond ((= () V2035) ()) ((cons? V2035) (if (element? (hd V2035) V2036) (cons (hd V2035) (intersection (tl V2035) V2036)) (intersection (tl V2035) V2036))) (true (shen.sys-error intersection))))
193
+
194
+ (defun reverse (V2037) (shen.reverse_help V2037 ()))
195
+
196
+ (defun shen.reverse_help (V2038 V2039) (cond ((= () V2038) V2039) ((cons? V2038) (shen.reverse_help (tl V2038) (cons (hd V2038) V2039))) (true (shen.sys-error shen.reverse_help))))
197
+
198
+ (defun union (V2040 V2041) (cond ((= () V2040) V2041) ((cons? V2040) (if (element? (hd V2040) V2041) (union (tl V2040) V2041) (cons (hd V2040) (union (tl V2040) V2041)))) (true (shen.sys-error union))))
199
+
200
+ (defun y-or-n? (V2042) (let Message (shen.prhush (shen.proc-nl V2042) (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
201
+ " (stoutput)) (y-or-n? V2042))))))))
202
+
203
+ (defun not (V2043) (if V2043 false true))
204
+
205
+ (defun subst (V2052 V2053 V2054) (cond ((= V2054 V2053) V2052) ((cons? V2054) (map (lambda W (subst V2052 V2053 W)) V2054)) (true V2054)))
206
+
207
+ (defun explode (V2056) (shen.explode-h (shen.app V2056 "" shen.a)))
208
+
209
+ (defun shen.explode-h (V2057) (cond ((= "" V2057) ()) ((shen.+string? V2057) (cons (pos V2057 0) (shen.explode-h (tlstr V2057)))) (true (shen.sys-error shen.explode-h))))
210
+
211
+ (defun cd (V2058) (set *home-directory* (if (= V2058 "") "" (shen.app V2058 "/" shen.a))))
212
+
213
+ (defun map (V2059 V2060) (shen.map-h V2059 V2060 ()))
214
+
215
+ (defun shen.map-h (V2063 V2064 V2065) (cond ((= () V2064) (reverse V2065)) ((cons? V2064) (shen.map-h V2063 (tl V2064) (cons (V2063 (hd V2064)) V2065))) (true (shen.sys-error shen.map-h))))
216
+
217
+ (defun length (V2066) (shen.length-h V2066 0))
218
+
219
+ (defun shen.length-h (V2067 V2068) (cond ((= () V2067) V2068) (true (shen.length-h (tl V2067) (+ V2068 1)))))
220
+
221
+ (defun occurrences (V2077 V2078) (cond ((= V2078 V2077) 1) ((cons? V2078) (+ (occurrences V2077 (hd V2078)) (occurrences V2077 (tl V2078)))) (true 0)))
222
+
223
+ (defun nth (V2086 V2087) (cond ((and (= 1 V2086) (cons? V2087)) (hd V2087)) ((cons? V2087) (nth (- V2086 1) (tl V2087))) (true (shen.sys-error nth))))
224
+
225
+ (defun integer? (V2088) (and (number? V2088) (let Abs (shen.abs V2088) (shen.integer-test? Abs (shen.magless Abs 1)))))
226
+
227
+ (defun shen.abs (V2089) (if (> V2089 0) V2089 (- 0 V2089)))
228
+
229
+ (defun shen.magless (V2090 V2091) (let Nx2 (* V2091 2) (if (> Nx2 V2090) V2091 (shen.magless V2090 Nx2))))
230
+
231
+ (defun shen.integer-test? (V2095 V2096) (cond ((= 0 V2095) true) ((> 1 V2095) false) (true (let Abs-N (- V2095 V2096) (if (> 0 Abs-N) (integer? V2095) (shen.integer-test? Abs-N V2096))))))
232
+
233
+ (defun mapcan (V2099 V2100) (cond ((= () V2100) ()) ((cons? V2100) (append (V2099 (hd V2100)) (mapcan V2099 (tl V2100)))) (true (shen.sys-error mapcan))))
234
+
235
+ (defun == (V2109 V2110) (cond ((= V2110 V2109) true) (true false)))
236
+
237
+ (defun abort () (simple-error ""))
238
+
239
+ (defun bound? (V2112) (and (symbol? V2112) (let Val (trap-error (value V2112) (lambda E shen.this-symbol-is-unbound)) (if (= Val shen.this-symbol-is-unbound) false true))))
240
+
241
+ (defun shen.string->bytes (V2113) (cond ((= "" V2113) ()) (true (cons (string->n (pos V2113 0)) (shen.string->bytes (tlstr V2113))))))
242
+
243
+ (defun maxinferences (V2114) (set shen.*maxinferences* V2114))
244
+
245
+ (defun inferences () (value shen.*infs*))
246
+
247
+ (defun protect (V2115) V2115)
248
+
249
+ (defun stoutput () (value *stoutput*))
250
+
251
+ (defun string->symbol (V2116) (let Symbol (intern V2116) (if (symbol? Symbol) Symbol (simple-error (cn "cannot intern " (shen.app V2116 " to a symbol" shen.s))))))
252
+
253
+ (defun shen.optimise (V2121) (cond ((= + V2121) (set shen.*optimise* true)) ((= - V2121) (set shen.*optimise* false)) (true (simple-error "optimise expects a + or a -.
254
+ "))))
255
+
256
+ (defun os () (value *os*))
257
+
258
+ (defun language () (value *language*))
259
+
260
+ (defun version () (value *version*))
261
+
262
+ (defun port () (value *port*))
263
+
264
+ (defun porters () (value *porters*))
265
+
266
+ (defun implementation () (value *implementation*))
267
+
268
+ (defun release () (value *release*))
269
+
270
+
271
+