home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / ckscripts / sexp < prev    next >
Lisp/Scheme  |  2020-01-01  |  4KB  |  203 lines

  1. set take echo on
  2. set sexp echo on
  3.  
  4. (pi)
  5. (t)
  6. (nil)
  7. ()
  8.  
  9. (setq a 2 b -1.3)
  10. (+ a b)
  11. (- 9 5 2 1)
  12. (* a (+ b 1) 3)
  13. (/ b a 2)
  14. (^ 3 2)
  15. (++ a 1.2)
  16. (-- a)
  17. (setq a 2 b -1.3)
  18. (abs (* a b 3))
  19. (max 1 2 3 4)
  20. (min 1 2 3 4)
  21. (mod 7 4 2)
  22. (float 1)
  23. (truncate 3.333)
  24. (ceiling 1.25)
  25. (floor 1.25)
  26. (round 1.75)
  27. (sqrt 2)
  28. (exp -1)
  29. (sin (/ pi 2))
  30. (cos pi)
  31. (tan pi)
  32. (log 2.7183)
  33. (log10 1000)
  34.  
  35. (++ a)
  36. (++ a 2)
  37. (-- a (* 2 pi))
  38. (++ a 1 b 1 c 1 d)
  39.  
  40. (= 1 1.0)
  41. (!= 1 1.0)
  42. (< 1 2 3)
  43. (<= 1 1 2 3)
  44. (> 3 2 1)
  45. (<= 3 3 2 1)
  46. (and 1 1 1 1 0)
  47. (or 1 1 1 1 0)
  48. (xor 3 1)
  49. (not 3)
  50.  
  51. (& 7 2)
  52. (| 1 2 3 4)
  53. (# 3 1)
  54. (~ 1)
  55.  
  56. (if (1) 2 3)
  57. (if t () t)
  58. (if t t ())
  59. (if nil t ())
  60. (if nil nil nil)
  61.  
  62. set sexp echo off
  63. (setq t1 \v(ftime))
  64. echo T LOOP START \m(t1)...
  65. (setq a 0 b 0 c 0 d 0)
  66. for \%i 1 10 1 {
  67.     (setq x (+ \frandom(\%i) 1))
  68.     (setq a (+ a x))
  69.     (setq b (+ b (^ x 2)))
  70.     (setq c (+ c (* x 2)))
  71.     (setq d (+ d (/ x 2)))
  72. }
  73. (setq t2 \v(ftime))
  74. echo T LOOP END \m(t2)...
  75. show mac a b c d
  76. echo TIME = \fsexp(- t2 t1)
  77.  
  78. set sexp echo on
  79. (setq a 1.5)
  80. (setq b 2.3)
  81. (setq i 3)
  82. (setq j 4)
  83. (+ a b)
  84. (= a b)
  85. (= a 1.5)
  86. (+ a j)
  87. (+ j i)
  88. (* a b)
  89. (- a b)
  90. (* 1000 (- a b))
  91. (/ a b)
  92. (mod a 1)
  93. (^ a b)
  94. (/ 10 3)
  95. (/ 10.0 3)
  96. (exp 1)
  97. (exp 2)
  98. (\v(math_pi))
  99. (exp \v(math_pi))
  100. (exp pi)
  101.  
  102. (setq a 2)
  103. (setq b 3)
  104. (setq c (+ a b))
  105. (* (+ a b) (- c a))
  106. (^ b a)
  107. echo {----}
  108. (- 2)
  109. (+ 2)
  110. (* 2)
  111. (/ 2)
  112. (setq \\%a (* (+ a b) (- c a)))
  113. echo \%a
  114. (setq \\%b (^ \%a 3))
  115. echo \%b
  116. (< a b)
  117. (> a b)
  118. (= a b)
  119. (= a 2)
  120.  
  121. set sexp echo off
  122. set take echo off
  123. echo STARTING STATS \v(ntime)...
  124.  
  125. dcl x = 2.7 3.14 -0.02 12.5 10 9 8 0 -4.2 3.1 10.01 6.666
  126. dcl y = 8.3 4.00 9.413 0.22 11 3 8 9 12.8 7.8 23.99 3.333
  127.  
  128.   (setq xsum 0 ysum 0 xsum2 0 ysum2 0 xysum 0)
  129.   (setq xmin (setq xmax \&x[1]) ymin (setq ymax \&y[1]))
  130.   (setq n \fdim(&x))
  131.  
  132. ; Loop through elements and accumulate sums, maxima, and minima
  133.  
  134.   for i 1 n 1 {
  135.       (setq x \&x[i] y \&y[i])                    ; Notational convenience
  136.       (setq xmax (max xmax x) ymax (max ymax y))  ; X and Y maxima
  137.       (setq xmin (min xmin x) ymin (min ymin y))  ; X and Y minima
  138.       (++ xsum x ysum y)                          ; X and Y sums
  139.       (++ xsum2 (^ x 2) ysum2 (^ y 2))            ; Sum of X and Y squares
  140.       (++ xysum (* x y))                          ; Sum of XY products
  141.   }
  142.  
  143. ; Calculate results
  144.  
  145.   (setq xmean (/ xsum n))                         ; Mean X
  146.   (setq ymean (/ ysum n))                         ; Mean Y
  147.   (setq xss (- xsum2 (/ (^ xsum 2) n)))           ; Intermediate values
  148.   (setq yss (- ysum2 (/ (^ ysum 2) n)))
  149.   (setq xyss (- xysum (/ (* xsum ysum) n)))
  150.   (setq xvar (/ xss n))                           ; X variance
  151.   (setq yvar (/ yss n))                           ; Y variance
  152.   (setq sdx (sqrt xvar))                          ; Std deviation in X
  153.   (setq sdy (sqrt yvar))                          ; Std deviation in Y
  154.   (setq tmp (* xss yss))
  155.   (setq cc (if tmp (/ xyss (sqrt tmp)) 1.0))      ; Correlation coefficient
  156.  
  157. echo STATS DONE \v(ntime)...
  158. sho mac xmean ymean xvar yvar sdx sdy cc
  159.  
  160. echo Macros...
  161.  
  162. set tak ec on
  163. set sexp ec on
  164.  
  165. define abc echo This is \%0
  166. (abc)
  167. (abc)
  168.  
  169. define def (* \%*)
  170. (def 2 3 4)
  171.  
  172. define ghi (* \%*), return \v(svalue)
  173. (ghi 4 5 6)
  174.  
  175. define objective return \fsexp(> \%1 100)
  176. define raise Echo Give a raise
  177. define demote Echo Take back company car
  178. define evaluate (if (objective \%1) raise demote)
  179. (setq result 120)
  180. (evaluate result)
  181. (setq result 90)
  182. (evaluate result)
  183.  
  184. echo
  185.  
  186. (.)
  187. (..)
  188. (. .)
  189. (+)
  190. (++)
  191. (+ +)
  192.  
  193. define FIBONACCI {
  194.     if < \%1 2 return \%1
  195.     return \fsexp(+ (fibonacci (- \%1 2)) (fibonacci (- \%1 1)))
  196. }
  197. (fibonacci 6)
  198. (setq a 2 b 4)
  199. (setq x (fibonacci (* a b )))
  200.  
  201. echo
  202. echo Done.
  203.