in 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. make "fun [
  2. [f]
  3. [
  4. return [
  5. [a b]
  6. [f :a :b]
  7. ]
  8. ]
  9. ]
  10. make "adder fun [[x y] [add :x :y]]
  11. print adder 2 "3
  12. make "imply fun [[x y] [or not :x :y]]
  13. print imply "true false
  14. print imply true true
  15. make "arr [ [ a b ] c ]
  16. print :arr[0]
  17. print :arr[1]
  18. print :arr[0][0]
  19. print :arr[0][1]
  20. make "arr[0][1] "d
  21. print :arr[0]
  22. print :arr[0][1]
  23. make "arr[1] [ add :a :d ]
  24. print :arr
  25. print arr 2 3
  26. make "arr[0][1] [ e [ f ] ]
  27. print :arr[0][1]
  28. print :arr[0][1][0]
  29. print :arr[0][1][1][0]
  30. print word "hello "world
  31. print word "hello TRUE
  32. print word "hello -134.5
  33. print sentence 483 "dba
  34. print sentence sentence [ [ a b ] c ] [ d [ e f ] ] [ g ]
  35. print list 483 "dba
  36. print list list [ [ a b ] c ] [ d [ e f ] ] [ g ]
  37. print join [ 483 ] "dba
  38. print join join [ [ a b ] c ] [ d [ e f ] ] [ g ]
  39. print first "hello
  40. print first butlast list list [ [ a b ] c ] [ d [ e f ] ] [ g ]
  41. make "pow [[a b] [
  42. if lt :b 1 [
  43. return 1
  44. ] [
  45. make "r pow :a div sub :b mod :b 2 2
  46. make "r mul :r :r
  47. if mod :b 2 [
  48. return mul :r :a
  49. ] [
  50. return :r
  51. ]
  52. print :r
  53. ]
  54. ]]
  55. print pow 2 18
  56. print readlist
  57. a b c 1 2 3
  58. make "reverse_list [
  59. [list]
  60. [if isempty :list [] [join reverse_list butfirst :list first :list]]
  61. ]
  62. print reverse_list [a b c d [e f] g]
  63. make "fib_wrap [
  64. [x]
  65. [
  66. make "fib [
  67. [x]
  68. [
  69. if lt :x 2 [return 1] []
  70. return add fib sub :x 1 fib sub :x 2
  71. ]
  72. ]
  73. fib :x
  74. ]
  75. ]
  76. print fib_wrap 0
  77. print fib_wrap 1
  78. print fib_wrap 2
  79. print fib_wrap 3
  80. print fib_wrap 4
  81. print fib_wrap 5
  82. print fib_wrap 6
  83. print fib_wrap 7
  84. print fib_wrap 8
  85. print fib_wrap 9
  86. make "f [[x] [
  87. make "g [[y] [return add :x :y]]
  88. return g 42
  89. ]]
  90. print f 233
  91. make "f1 [[x] [
  92. make "g1 [[y] [return add :x :y]]
  93. return :g1
  94. ]]
  95. make "c1 f1 42
  96. make "c2 f1 24
  97. print c1 1
  98. print c2 2
  99. make "curry_two [[f x] [
  100. return [[y] [return f :x :y]]
  101. ]]
  102. make "f2 [[x y] [
  103. return add :x :y
  104. ]]
  105. make "f3 curry_two :f2 42
  106. print f3 233
  107. make "fun [
  108. [x]
  109. [[[y] [make "x add :x :y]]]
  110. ]
  111. make "adder fun 5
  112. print adder 1
  113. print adder 2
  114. print adder 3
  115. print "abcd12
  116. make "a 16
  117. print :a
  118. make "b "a
  119. print thing :b
  120. make "c mul add :a 13 :a
  121. print if false [] [print sub :c "6]
  122. print div 12 5
  123. print mod 12 5
  124. make "d read
  125. 1234dd
  126. make "e print :d
  127. print :e
  128. make "prt [
  129. [a]
  130. [
  131. make "b [
  132. []
  133. [print :a]
  134. ]
  135. return :b
  136. ]
  137. ]
  138. make "c prt "hello
  139. c
  140. make "x 2
  141. print :x
  142. make "test [
  143. []
  144. [
  145. make "x 1
  146. export "x
  147. print :x
  148. ]
  149. ]
  150. test
  151. print :x