in 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. print "abcd12
  2. make "a 16
  3. print :a
  4. make "b "a
  5. print thing :b
  6. make "c mul add :a 13 :a
  7. print sub :c "6
  8. print div 12 5
  9. print mod 12 5
  10. make "d read
  11. 1234dd
  12. make "e print :d
  13. print :e
  14. make "l []
  15. make "q join :l "[
  16. print :q[0]
  17. print eq "] "\]
  18. make "t print [ \[1\]\\\] [1]]
  19. print islist :t[0]
  20. print islist :t[1]
  21. make "x "t
  22. make "y "x
  23. print :::y
  24. make "rev_func [
  25. [f]
  26. [
  27. [
  28. [a b]
  29. [f :b :a]
  30. ]
  31. ]
  32. ]
  33. make "rev_sub rev_func [[x y] [sub :x :y]]
  34. print rev_sub 2 5
  35. print rev_sub 26.5 10.3
  36. make "rev_ge rev_func [[x y] [or gt :x :y eq :x :y]]
  37. print rev_ge 3 7
  38. print rev_ge "abc "aBc
  39. print rev_ge 8 8
  40. make "rev_imply rev_func [[x y] [or not :x :y]]
  41. print rev_imply false false
  42. print rev_imply false true
  43. print rev_imply true false
  44. print rev_imply true true
  45. make "arr [ [ a b ] c ]
  46. print :arr[0]
  47. print :arr[1]
  48. print :arr[0][0]
  49. print :arr[0][1]
  50. make "arr[0][1] "d
  51. print :arr[0]
  52. print :arr[0][1]
  53. make "arr[1] [ add :a :d ]
  54. print :arr
  55. print arr 2 3
  56. make "arr[0][1] [ e [ f ] ]
  57. make "arr join :arr [ g [ h i ] ]
  58. print :arr[0][1]
  59. print :arr[0][1][0]
  60. print :arr[0][1][1][0]
  61. make "x 1
  62. print :arr[x:]
  63. print word "hello "world
  64. print word "hello TRUE
  65. print word "hello -134.5
  66. print sentence 483 "dba
  67. print sentence sentence [ [ a b ] c ] [ d [ e f ] ] [ g ]
  68. print list 483 "dba
  69. print list list [ [ a b ] c ] [ d [ e f ] ] [ g ]
  70. print join [ 483 ] "dba
  71. print join join [ [ a b ] c ] [ d [ e f ] ] [ g ]
  72. print first "hello
  73. print first butlast list list [ [ a b ] c ] [ d [ e f ] ] [ g ]
  74. make "pow [[a b] [
  75. if lt :b 1 [
  76. return 1
  77. ] [
  78. make "r pow :a div sub :b mod :b 2 2
  79. make "r mul :r :r
  80. if mod :b 2 [
  81. return mul :r :a
  82. ] [
  83. return :r
  84. ]
  85. print :r
  86. ]
  87. ]]
  88. print pow 2 18
  89. print readlist
  90. a b c 1 2 3
  91. make "reverse_list [
  92. [list]
  93. [if isempty :list [] [join reverse_list butfirst :list first :list]]
  94. ]
  95. print reverse_list []
  96. print reverse_list [x y z]
  97. print reverse_list [12 345 6 78 9 0]
  98. print reverse_list [a b c d [e f] g]
  99. print reverse_list [h [i [j k]] l m n]
  100. make "fib_wrap [
  101. [x]
  102. [
  103. make "fib [
  104. [x]
  105. [
  106. if lt :x 2 [return 1] []
  107. return add fib sub :x 1 fib sub :x 2
  108. ]
  109. ]
  110. fib :x
  111. ]
  112. ]
  113. print fib_wrap 0
  114. print fib_wrap 1
  115. print fib_wrap 2
  116. print fib_wrap 3
  117. print fib_wrap 4
  118. print fib_wrap 5
  119. print fib_wrap 6
  120. print fib_wrap 7
  121. print fib_wrap 8
  122. print fib_wrap 9
  123. make "f [[x] [
  124. make "g [[y] [return add :x :y]]
  125. return g 42
  126. ]]
  127. print f 233
  128. make "f1 [[x] [
  129. make "g1 [[y] [return add :x :y]]
  130. return :g1
  131. ]]
  132. make "c1 f1 42
  133. make "c2 f1 24
  134. print c1 1
  135. print c2 2
  136. make "curry_two [[f x] [
  137. return [[y] [return f :x :y]]
  138. ]]
  139. make "f2 [[x y] [
  140. return add :x :y
  141. ]]
  142. make "f3 curry_two :f2 42
  143. print f3 233
  144. make "fun [
  145. [x]
  146. [[[y] [make "x add :x :y]]]
  147. ]
  148. make "adder fun 5
  149. print adder 1
  150. print adder 2
  151. print adder 3
  152. make "prt [
  153. [a]
  154. [
  155. make "b [
  156. []
  157. [print :a]
  158. ]
  159. return :b
  160. ]
  161. ]
  162. make "c prt "hello
  163. c
  164. make "x 2
  165. print :x
  166. make "test [
  167. []
  168. [
  169. make "x 1
  170. export "x
  171. print :x
  172. ]
  173. ]
  174. test
  175. print :x
  176. print poall
  177. make "fun1 [
  178. [x]
  179. [add :x 10]
  180. ]
  181. print fun1 5
  182. make "fun2 [
  183. []
  184. [
  185. print fun1 5
  186. make "fun1 [
  187. [x]
  188. [add :x 100]
  189. ]
  190. print fun1 5
  191. export "fun1
  192. make "fun1 [
  193. [x]
  194. [add :x 1000]
  195. ]
  196. print fun1 5
  197. if eq fun1 5 1005 [return 0] []
  198. make "fun1 [
  199. [x]
  200. [add :x 10000]
  201. ]
  202. export "fun1
  203. print fun1 5
  204. return 1
  205. ]
  206. ]
  207. print fun2
  208. print fun1 5