Advertisement
Gallefray

almost there?

Aug 7th, 2015
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lisp 10.10 KB | None | 0 0
  1.  
  2. user@FinnandthethreeFurys ~
  3. $ clisp
  4.   i i i i i i i       ooooo    o        ooooooo   ooooo   ooooo
  5.   I I I I I I I      8     8   8           8     8     o  8    8
  6.   I  \ `+' / I      8         8           8     8        8    8
  7.    \  `-+-' /      8         8           8      ooooo   8oooo
  8.     `-__|__-'        8         8           8           8  8
  9.         |            8     o   8           8     o     8  8
  10.   ------+------       ooooo    8oooooo  ooo8ooo   ooooo   8
  11.  
  12. Welcome to GNU CLISP 2.49+ (2010-07-17) <http://clisp.org/>
  13.  
  14. Copyright (c) Bruno Haible, Michael Stoll 1992, 1993
  15. Copyright (c) Bruno Haible, Marcus Daniels 1994-1997
  16. Copyright (c) Bruno Haible, Pierpaolo Bernardi, Sam Steingold 1998
  17. Copyright (c) Bruno Haible, Sam Steingold 1999-2000
  18. Copyright (c) Sam Steingold, Bruno Haible 2001-2010
  19.  
  20. Type :h and hit Enter for context help.
  21.  
  22. [1]> (position 'x '(x y z))
  23. 0
  24. [2]> (member 'z '(x y z))
  25. (Z)
  26. [3]> (member 'z '(x y))
  27. NIL
  28. [4]> #'isevenp
  29.  
  30. *** - FUNCTION: undefined function ISEVENP
  31. The following restarts are available:
  32. USE-VALUE      :R1      Input a value to be used instead of (FDEFINITION 'ISEVENP).
  33. RETRY          :R2      Retry
  34. STORE-VALUE    :R3      Input a new value for (FDEFINITION 'ISEVENP).
  35. ABORT          :R4      Abort main loop
  36. Break 1 [5]> :R4
  37. [6]> #'evenp
  38. #<SYSTEM-FUNCTION EVENP>
  39. [7]> (evenp 2)
  40. T
  41. [8]> (map #'evenp '(2 3 4 5 6 7 8))
  42.  
  43. *** - EVAL: too few arguments given to MAP: (MAP #'EVENP '(2 3 4 5 6 7 8))
  44. The following restarts are available:
  45. ABORT          :R1      Abort main loop
  46. Break 1 [9]> ABORT
  47. [10]> (map 'list #'evenp '(2 3 4 5 6 7 8))
  48. (T NIL T NIL T NIL T)
  49. [11]> (map 'boolean #'evenp '(2 3 4 5 6 7 8))
  50.  
  51. *** - There are no sequences of type BOOLEAN
  52. The following restarts are available:
  53. ABORT          :R1      Abort main loop
  54. Break 1 [12]> ABORT
  55. [13]> (map 'bool #'evenp '(2 3 4 5 6 7 8))
  56.  
  57. *** - There are no sequences of type BOOL
  58. The following restarts are available:
  59. ABORT          :R1      Abort main loop
  60. Break 1 [14]> ABORT
  61. [15]> ABORT
  62.  
  63. *** - SYSTEM::READ-EVAL-PRINT: variable ABORT has no value
  64. The following restarts are available:
  65. USE-VALUE      :R1      Input a value to be used instead of ABORT.
  66. STORE-VALUE    :R2      Input a new value for ABORT.
  67. ABORT          :R3      Abort main loop
  68. Break 1 [16]> ABORT
  69. [17]> (map t #'evenp '(2 3 4 5 6 7 8))
  70.  
  71. *** - There are no sequences of type T
  72. The following restarts are available:
  73. ABORT          :R1      Abort main loop
  74. Break 1 [18]> ABORT
  75. [19]> (map nil #'evenp '(2 3 4 5 6 7 8))
  76. NIL
  77. [20]> (map null #'evenp '(2 3 4 5 6 7 8))
  78.  
  79. *** - SYSTEM::READ-EVAL-PRINT: variable NULL has no value
  80. The following restarts are available:
  81. USE-VALUE      :R1      Input a value to be used instead of NULL.
  82. STORE-VALUE    :R2      Input a new value for NULL.
  83. ABORT          :R3      Abort main loop
  84. Break 1 [21]> ABORT
  85. [22]> (map 'null #'evenp '(2 3 4 5 6 7 8))
  86.  
  87. *** - MAP: sequence type forces length 0, but result has length 7
  88. The following restarts are available:
  89. ABORT          :R1      Abort main loop
  90. Break 1 [23]> ABORT
  91. [24]> (map 'list #'evenp '(2 3 4 5 6 7 8))
  92. (T NIL T NIL T NIL T)
  93. [25]> (find nil (map 'list (lambda (n) (if (= (mod n 3) 0) nil t))))
  94.  
  95. *** - EVAL: too few arguments given to MAP:
  96.       (MAP 'LIST (LAMBDA (N) (IF (= (MOD N 3) 0) NIL T)))
  97. The following restarts are available:
  98. ABORT          :R1      Abort main loop
  99. Break 1 [26]> abort
  100. [27]> (find nil (map 'list (lambda (n) (if (= (mod n 3) 0) nil t)) '(2 3 4 5 6 7 8 9)))
  101. NIL
  102. [28]> (map 'list (lambda (n) (if (= (mod n 3) 0) nil t)) '(2 3 4 5 6 7 8 9))
  103. (T NIL T T NIL T T NIL)
  104. [29]> (find t (map 'list (lambda (n) (if (= (mod n 3) 0) nil t)) '(2 3 4 5 6 7 8 9)))
  105. T
  106. [30]> (member t (map 'list (lambda (n) (if (= (mod n 3) 0) nil t)) '(2 3 4 5 6 7 8 9)))
  107. (T NIL T T NIL T T NIL)
  108. [31]> (find t (map 'list (lambda (n) (if (= (mod n 3) 0) nil t)) '(2 3 4 5 6 7 8 9)))
  109. T
  110. [32]> (defun ook (i) (find t (map 'list (lambda (n) (if (= (mod n i) 0) nil t)) '(2 3 4 5 6 7 8 9 10))))
  111. OOK
  112. [33]> (ook 3)
  113. T
  114. [34]> (ook 4)
  115. T
  116. [35]> (defun ook (i) (find t (map 'list (lambda (n) (if (= (mod n i) 0) nil t)) '(2 3 4 5 6 7 8 9 10))))
  117. OOK
  118. [36]> (ook 20)
  119. T
  120. [37]> (defun ook (i) (find t (map 'list (lambda (n) (if (= (mod i n) 0) nil t)) '(2 3 4 5 6 7 8 9 10))))
  121. OOK
  122. [38]> (ook 20)
  123. T
  124. [39]> (defun ook (i lis) (find t (map 'list (lambda (n) (if (= (mod i n) 0) nil t)) lis)))
  125. OOK
  126. [40]> (ook 3 '(4 5))
  127. T
  128. [41]> (ook 3 '(4 6))
  129. T
  130. [42]> (ook 3 '(3 6))
  131. T
  132. [43]> (ook 3 '())
  133. NIL
  134. [44]> (defun ook (i lis) (map 'list (lambda (n) (if (= (mod i n) 0) nil t)) lis))
  135. OOK
  136. [45]> (ook 3 '(3 6))
  137. (NIL T)
  138. [46]> (ook 3 '(4 6))
  139. (T T)
  140. [47]> (defun ook (i lis) (find t (map 'list (lambda (n) (if (= (mod i n) 0) t nil)) lis)))
  141. OOK
  142. [48]> (ook 3 '(3 6))
  143. T
  144. [49]> (ook 3 '(4 5))
  145. NIL
  146. [50]> (defun frodo (divs lis) (find t (map 'list (lambda (n) (if (ook n lis) t nil)) lis))
  147. )
  148. FRODO
  149. [51]> (frodo '(3 5) '(1 2))
  150. T
  151. [52]> (frodo '(3 5) '(3 5))
  152. T
  153. [53]> (frodo '(3 5) '(6 10))
  154. T
  155. [54]> (defun frodo (divs lis) (map 'list (lambda (n) (if (ook n lis) t nil)) lis))
  156. FRODO
  157. [55]> (frodo '(3 5) '(6 10))
  158. (T T)
  159. [56]> (frodo '(3 5) '(1))
  160. (T)
  161. [57]> (defun frodo (divs lis) (map 'list (lambda (n) (ook n lis)) lis))         FRODO
  162. [58]> (frodo '(3 5) '(1))
  163. (T)
  164. [59]> (frodo '(3 5) '(20))
  165. (T)
  166. [60]> (defun frodo (divs lis) (map 'list (lambda (n) (if (ook n lis) t nil)) divs))
  167. FRODO
  168. [61]> (frodo '(3 5) '(20))
  169. (NIL NIL)
  170. [62]> (defun frodo (divs lis) (find t (map 'list (lambda (n) (if (ook n lis) t nil)) divs)))
  171. FRODO
  172. [63]> (frodo '(3 5) '(20))
  173. NIL
  174. [64]> (frodo '(3 5) '(3 5))
  175. T
  176. [65]> (frodo '(3 5) '(1 3 5 7 11))
  177. T
  178. [66]> (defun frodo (divs lis) (map 'list (lambda (n) (if (ook n lis) t nil)) divs))
  179. FRODO
  180. [67]> (frodo '(3 5) '(1 3 5 7 11))                                              (T T)
  181. [68]> (defun frodo (divs lis) (map 'list (lambda (n) (ook n lis)) divs))        FRODO
  182. [69]> (frodo '(3 5) '(1 3 5 7 11))
  183. (T T)
  184. [70]> (defun ook (i lis) (find-if-not nil (map 'list (lambda (n) (if (= (mod i n) 0) n nil)) lis)))
  185. OOK
  186. [71]> (ook 3 '(2 3 5))
  187.  
  188. *** - FUNCALL: undefined function NIL
  189. The following restarts are available:
  190. USE-VALUE      :R1      Input a value to be used instead of (FDEFINITION 'NIL).
  191. RETRY          :R2      Retry
  192. STORE-VALUE    :R3      Input a new value for (FDEFINITION 'NIL).
  193. ABORT          :R4      Abort main loop
  194. Break 1 [72]> ABORT
  195. [73]> #'nilp
  196.  
  197. *** - FUNCTION: undefined function NILP
  198. The following restarts are available:
  199. USE-VALUE      :R1      Input a value to be used instead of (FDEFINITION 'NILP).
  200. RETRY          :R2      Retry
  201. STORE-VALUE    :R3      Input a new value for (FDEFINITION 'NILP).
  202. ABORT          :R4      Abort main loop
  203. Break 1 [74]> ABORT
  204. [75]> #'isnil
  205.  
  206. *** - FUNCTION: undefined function ISNIL
  207. The following restarts are available:
  208. USE-VALUE      :R1      Input a value to be used instead of (FDEFINITION 'ISNIL).
  209. RETRY          :R2      Retry
  210. STORE-VALUE    :R3      Input a new value for (FDEFINITION 'ISNIL).
  211. ABORT          :R4      Abort main loop
  212. Break 1 [76]> abort
  213. [77]> (defun ook (i lis) (find-if-not #'not (map 'list (lambda (n) (if (= (mod i n) 0) n nil)) lis)))
  214. OOK
  215. [78]> (ook 3 '(2 3 5))
  216. 3
  217. [79]> (ook 3 '(2 5))
  218. NIL
  219. [80]> (ook 3 '(2 3 5 9))
  220. 3
  221. [81]> (defun ook (i lis) (map 'list (lambda (n) (if (= (mod i n) 0) n nil)) lis))
  222. OOK
  223. [82]> (ook 3 '(2 3 5 9))
  224. (NIL 3 NIL NIL)
  225. [83]> (defun ook (i lis) (remove nil (map 'list (lambda (n) (if (= (mod i n) 0) n nil)) lis)))
  226. OOK
  227. [84]> (ook 3 '(2 3 5 9))
  228. (3)
  229. [85]> (frodo '(3 5) '(1 3 5 7 11))                                              ((1 3) (1 5))
  230. [86]> (union (frodo '(3 5) '(1 3 5 7 11)))
  231.  
  232. *** - EVAL: too few arguments given to UNION:
  233.       (UNION (FRODO '(3 5) '(1 3 5 7 11)))
  234. The following restarts are available:
  235. ABORT          :R1      Abort main loop
  236. Break 1 [87]> ABORT
  237. [88]> abort
  238.  
  239. *** - SYSTEM::READ-EVAL-PRINT: variable ABORT has no value
  240. The following restarts are available:
  241. USE-VALUE      :R1      Input a value to be used instead of ABORT.
  242. STORE-VALUE    :R2      Input a new value for ABORT.
  243. ABORT          :R3      Abort main loop
  244. Break 1 [89]> abort
  245. [90]> (union (frodo '(3 5) '(1 3 5 7 11)) (frodo '(3 5) '(1 3 5 7 11)))
  246. ((1 3) (1 5) (1 3) (1 5))
  247. [91]> (union (cdr (frodo '(3 5) '(1 3 5 7 11))) (cdr (frodo '(3 5) '(1 3 5 7 11))))
  248. ((1 5) (1 5))
  249. [92]> (remove-duplicates (frodo '(3 5) '(1 3 5 7 11)))
  250. ((1 3) (1 5))
  251. [93]> (frodo '(3 5) '(1 3 5 7 11))
  252. ((1 3) (1 5))
  253. [94]> (union ,@(frodo '(3 5) '(1 3 5 7 11)))
  254.  
  255. *** - READ: comma is illegal outside of backquote
  256. The following restarts are available:
  257. ABORT          :R1      Abort main loop
  258. Break 1 [95]> abort
  259. [96]> `(union ,@(frodo '(3 5) '(1 3 5 7 11)))
  260. (UNION (1 3) (1 5))
  261. [97]> (defmacro unpack (f lis)
  262.         `(f ,@lis))
  263. UNPACK
  264. [98]> (unpack #'union (frodo '(3 5) '(1 3 5 7 11)))
  265.  
  266. *** - EVAL: undefined function F
  267. The following restarts are available:
  268. USE-VALUE      :R1      Input a value to be used instead of (FDEFINITION 'F).
  269. RETRY          :R2      Retry
  270. STORE-VALUE    :R3      Input a new value for (FDEFINITION 'F).
  271. ABORT          :R4      Abort main loop
  272. Break 1 [99]> abort
  273. [100]> (defmacro unpack-join (lis)
  274.         `(union ,@lis))
  275. UNPACK-JOIN
  276. [101]> (unpack-join (frodo '(3 5) '(1 3 5 7 11)))
  277.  
  278. *** - SYSTEM::READ-EVAL-PRINT: variable FRODO has no value
  279. The following restarts are available:
  280. USE-VALUE      :R1      Input a value to be used instead of FRODO.
  281. STORE-VALUE    :R2      Input a new value for FRODO.
  282. ABORT          :R3      Abort main loop
  283. Break 1 [102]> abort
  284. [103]> (unpack-join '(frodo '(3 5) '(1 3 5 7 11)))
  285.  
  286. *** - SYSTEM::READ-EVAL-PRINT: variable QUOTE has no value
  287. The following restarts are available:
  288. USE-VALUE      :R1      Input a value to be used instead of QUOTE.
  289. STORE-VALUE    :R2      Input a new value for QUOTE.
  290. ABORT          :R3      Abort main loop
  291. Break 1 [104]> abort
  292. [105]> #'defvar
  293.  
  294. *** - FUNCTION: undefined function DEFVAR
  295. The following restarts are available:
  296. USE-VALUE      :R1      Input a value to be used instead of (FDEFINITION 'DEFVAR).
  297. RETRY          :R2      Retry
  298. STORE-VALUE    :R3      Input a new value for (FDEFINITION 'DEFVAR).
  299. ABORT          :R4      Abort main loop
  300. Break 1 [106]> abort
  301. [107]>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement