in 2.3 KB

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