id int64 0 45.1k | file_name stringlengths 4 68 | file_path stringlengths 14 193 | content stringlengths 32 9.62M | size int64 32 9.62M | language stringclasses 1
value | extension stringclasses 6
values | total_lines int64 1 136k | avg_line_length float64 3 903k | max_line_length int64 3 4.51M | alphanum_fraction float64 0 1 | repo_name stringclasses 779
values | repo_stars int64 0 882 | repo_forks int64 0 108 | repo_open_issues int64 0 90 | repo_license stringclasses 8
values | repo_extraction_date stringclasses 146
values | sha stringlengths 64 64 | __index_level_0__ int64 0 45.1k | exdup_ids_cmlisp_stkv2 listlengths 1 47 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
17,064 | ex-08-11.lisp | joncdavid_touretzky-lisp-exercises/chp8-recursion/ex-08-11.lisp | ; file: ex-08-11.lisp
; author: Jon David
; date: Monday, August 18, 2014
; description:
; exercise 8.11 - Define a fibonacci function. Where
; Fib(0) and Fib(1) both equal 1.
(defun fib (n)
(cond ((equal n 0) 1)
((equal n 1) 1)
(t (+ (fib (- n 1)) (fib (- n 2))))))
| 276 | Common Lisp | .lisp | 10 | 26.1 | 54 | 0.611321 | joncdavid/touretzky-lisp-exercises | 3 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:27:44 AM (Europe/Amsterdam) | 13c361d6c535187f794f539938070226f826d9a8a3ce6bb81d43bac09882cea1 | 17,064 | [
-1
] |
17,065 | ex-08-58.lisp | joncdavid_touretzky-lisp-exercises/chp8-recursion/ex-08-58.lisp | ; file: ex-08-58.lisp
; author: Jon David
; date: Monday, September 29, 2014
; description:
; exercise 8.58 - Write MERGE-LISTS, a function that takes two lists
; of numbers, each in increasing order, as input. The function should
; return a list that is a merger of the elements in its inputs, in
; order. (MERG... | 781 | Common Lisp | .lisp | 21 | 35.047619 | 71 | 0.629482 | joncdavid/touretzky-lisp-exercises | 3 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:27:44 AM (Europe/Amsterdam) | ff18178068273533a3b4681b68613f2182f1451f3388d2eabacbbe99f380958f | 17,065 | [
-1
] |
17,066 | ex-08-36.lisp | joncdavid_touretzky-lisp-exercises/chp8-recursion/ex-08-36.lisp | ; file: ex-08-36.lisp
; author: Jon David
; date: Monday, August 25, 2014
; description:
; exercise 8.36 - The function COUNT-ODD counts the number of odd
; elements in a list of numbers; for example, (COUNT-ODD '(4 5 6 7 8))
; should return two. Show how to write COUNT-ODD using conditional
; augmentation. The... | 789 | Common Lisp | .lisp | 19 | 39.578947 | 72 | 0.691406 | joncdavid/touretzky-lisp-exercises | 3 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:27:44 AM (Europe/Amsterdam) | 0ef0b6f8e9381d9fa4351570e216a7102f29921fad881d479fadf27faf4a7997 | 17,066 | [
-1
] |
17,067 | ex-05-01.lisp | joncdavid_touretzky-lisp-exercises/chp5-variables-and-side-effects/ex-05-01.lisp | ; file: ex-05-01.lisp
; author: Jon David
; date: Tuesday, July 15, 2014
; description:
; exercise 5.1 - Rewrite function POOR-STYLE to create a new local
; variable Q using LET, instead of using SETF to change P. Call your
; new function GOOD-STYLE.
(defun poor-style (p)
; This is the original definition of POO... | 637 | Common Lisp | .lisp | 19 | 31.473684 | 70 | 0.677524 | joncdavid/touretzky-lisp-exercises | 3 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:27:44 AM (Europe/Amsterdam) | 4f751ec3da051154a204acc8f7825eaf2e198c3dbb83ce585118e32fc902d7f8 | 17,067 | [
-1
] |
17,068 | ex-05-02.lisp | joncdavid_touretzky-lisp-exercises/chp5-variables-and-side-effects/ex-05-02.lisp | ; file: ex-05-02-thru-05.lisp
; author: Jon David
; date: Tuesday, July 15, 2014
; description:
; exercises 5.2 thru 5.5
; Q5.2: What is a side effect?
; Q5.3: What is the difference between a local and global variable
| 227 | Common Lisp | .lisp | 7 | 30.857143 | 67 | 0.714286 | joncdavid/touretzky-lisp-exercises | 3 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:27:44 AM (Europe/Amsterdam) | 039d61f8cca4ee407ff987b5b670567e2951cfe0f5f613af18067b80b9d9e2fd | 17,068 | [
-1
] |
17,069 | ex-05-06-keyboard-exercise.lisp | joncdavid_touretzky-lisp-exercises/chp5-variables-and-side-effects/ex-05-06-keyboard-exercise.lisp | ; file: ex-05-06-keyboard-exercise.lisp
; author: Jon David
; date: Tuesday, July 15, 2014
; description:
; exercise 5.6 - This keyboard exercise is about dice. We will start
; with a function to throw one die and end up with a program to play
; craps. Be sure to include a documentation string for each function
;... | 6,606 | Common Lisp | .lisp | 152 | 40.381579 | 100 | 0.629998 | joncdavid/touretzky-lisp-exercises | 3 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:27:44 AM (Europe/Amsterdam) | c80846c67344356904ddc92358ee311efc07611b02b186deb0cecfe80c80426b | 17,069 | [
-1
] |
17,070 | ex-07-01.lisp | joncdavid_touretzky-lisp-exercises/chp7-applicative-programming/ex-07-01.lisp | ; file: ex-07-01.lisp
; author: Jon David
; date: Sunday, August 03, 2014
; description:
; exercise 7.1 - Write an ADD1 function that adds one to its input.
; Then write an expression to add one to each element of the list
; (1 3 5 7 9).
;
(defun add1 (n)
(+ 1 n))
(defun ut-add1 ()
(let* ((test-list '(1 3 5... | 424 | Common Lisp | .lisp | 15 | 26.2 | 69 | 0.649383 | joncdavid/touretzky-lisp-exercises | 3 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:27:44 AM (Europe/Amsterdam) | 7039406072f0c57ab104844786f4205c7a8e115d71cd91b0313c0ab819b6c2a6 | 17,070 | [
-1
] |
17,071 | ex-07-29-keyboard-exercise.lisp | joncdavid_touretzky-lisp-exercises/chp7-applicative-programming/ex-07-29-keyboard-exercise.lisp | ; file: ex-07-29-keyboard-exercise.lisp
; author: Jon David
; date: Thursday, August 07, 2014
; description:
; exercise 7.29 - If the blocks database is already stored on the
; computer for you, load the file containing it. If not, you will
; have to type it in as it appears in Figure 7-3 (page 223). Save
; the... | 6,709 | Common Lisp | .lisp | 160 | 39.26875 | 70 | 0.691576 | joncdavid/touretzky-lisp-exercises | 3 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:27:44 AM (Europe/Amsterdam) | e80d3eba8b724fbba0c59be90a60fea79fb77b06f11fa1a3748828d7f961cb3d | 17,071 | [
-1
] |
17,072 | ex-07-14.lisp | joncdavid_touretzky-lisp-exercises/chp7-applicative-programming/ex-07-14.lisp | ; file: ex-07-14.lisp
; author: Jon David
; date: Monday, August 04, 2014
; description:
; exercise 7.14 - Here is a version of SET-DIFFERENCE written with
; REMOVE-IF:
;
; (defun my-setdiff (x y)
; (remove-if #'(lambda (e) (member e y))
; x))
;
; Show how the INTERSECTION and UNION function... | 537 | Common Lisp | .lisp | 18 | 28.222222 | 70 | 0.639535 | joncdavid/touretzky-lisp-exercises | 3 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:27:44 AM (Europe/Amsterdam) | e0b2248958d54cec63e3c010d351f70733a58830fbece026b66333e83b4e75af | 17,072 | [
-1
] |
17,073 | ex-07-02.lisp | joncdavid_touretzky-lisp-exercises/chp7-applicative-programming/ex-07-02.lisp | ; file: ex-07-02.lisp
; author: Jon David
; date: Sunday, August 03, 2014
; description:
; exercise 7.2 - Let the global variable DAILY-PLANET contain the
; following table:
(setf daily-planet '((olsen jimmy 123-76-4535 cub-reporter)
(kent clark 089-52-6787 reporter)
(lane lois 951-26-1438 reporter... | 709 | Common Lisp | .lisp | 17 | 38.764706 | 67 | 0.707849 | joncdavid/touretzky-lisp-exercises | 3 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:27:44 AM (Europe/Amsterdam) | 74174657fdbfd58014fbd64f234ba2859f257149654456e357f60efba864cacf | 17,073 | [
-1
] |
17,074 | ex-07-11.lisp | joncdavid_touretzky-lisp-exercises/chp7-applicative-programming/ex-07-11.lisp | ; file: ex-07-11-keyboard-exercise.lisp
; author: Jon David
; date: Sunday, August 03, 2014
; description:
; exercise 7.11 - Write a function to pick out those numbers in a
; list that are greater than one and less than five.
(defun pick-numbers (numbers-list)
(remove-if-not #'(lambda (n) (and (> n 1) (< n 5))) n... | 499 | Common Lisp | .lisp | 13 | 36.230769 | 68 | 0.677019 | joncdavid/touretzky-lisp-exercises | 3 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:27:44 AM (Europe/Amsterdam) | 1771e3f5874ffa27ab6de1171a84b7cb03972d87ad0ba302936427dbb91c64e0 | 17,074 | [
-1
] |
17,075 | ex-07-04.lisp | joncdavid_touretzky-lisp-exercises/chp7-applicative-programming/ex-07-04.lisp | ; file: ex-07-04.lisp
; author: Jon David
; date: Sunday, August 03, 2014
; description:
; exercise 7.4 - Suppose we want to solve a problem similar to the
; preceding one, but instead of testing whether an element is zero,
; we want to test whether it is greater than five. We can't use >
; directly because > i... | 704 | Common Lisp | .lisp | 17 | 39.647059 | 69 | 0.699708 | joncdavid/touretzky-lisp-exercises | 3 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:27:44 AM (Europe/Amsterdam) | ea3d90d8000c9b5f7dc00ac6afacfa90ef7cdc53eba1aed029455dca860085a5 | 17,075 | [
-1
] |
17,076 | ex-07-27.lisp | joncdavid_touretzky-lisp-exercises/chp7-applicative-programming/ex-07-27.lisp | ; file: ex-07-27.lisp
; author: Jon David
; date: Thursday, August 07, 2014
; description:
; exercise 7.27 - Show how to write EVERY given REMOVE-IF.
; EVERY returns true if predicate returns true for all elements.
; REMOVE-IF will return an empty list if predicate is true for all
; elements.
; REMOVE-IF = EVERY, o... | 539 | Common Lisp | .lisp | 14 | 36.714286 | 66 | 0.708015 | joncdavid/touretzky-lisp-exercises | 3 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:27:44 AM (Europe/Amsterdam) | 762a71f2c52ec701e4c1f4feea61ec33bbcb26e5bfdda876c00087413dc72912 | 17,076 | [
-1
] |
17,077 | ex-07-03.lisp | joncdavid_touretzky-lisp-exercises/chp7-applicative-programming/ex-07-03.lisp | ; file: ex-07-03.lisp
; author: Jon David
; date: Sunday, August 03, 2014
; description:
; exercise 7.3 - Write an expression to apply the ZEROP predicate to
; each element of the list (2 0 3 4 0 -5 -6). The answer you get
; should be a list of Ts and NILs.
(defun ut-ex-07-03 ()
(let* ((test-list '(2 0 3 4 0 -... | 438 | Common Lisp | .lisp | 12 | 34.416667 | 70 | 0.661939 | joncdavid/touretzky-lisp-exercises | 3 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:27:44 AM (Europe/Amsterdam) | 346e7b5ab19cad7a32eb1c3a6bcc9f67c2f03cbcba9141d86f64e58cac5a289b | 17,077 | [
-1
] |
17,078 | ex-07-12.lisp | joncdavid_touretzky-lisp-exercises/chp7-applicative-programming/ex-07-12.lisp | ; file: ex-07-12.lisp
; author: Jon David
; date: Monday, August 04, 2014
; description:
; exercise 7.12 - Write a function that counts how many times the
; word "the" appears in a sentence.
(defun count-thes (sentence)
(length (remove-if-not #'(lambda (n) (equal n 'the)) sentence)))
(defun ut-count-thes ()
(l... | 450 | Common Lisp | .lisp | 13 | 32.384615 | 67 | 0.690531 | joncdavid/touretzky-lisp-exercises | 3 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:27:44 AM (Europe/Amsterdam) | c192ba005f38cec2017fcbf9dc37e2c5a571245a475a3c90d6ab483c35b4bd2c | 17,078 | [
-1
] |
17,079 | ex-07-10-keyboard-exercise.lisp | joncdavid_touretzky-lisp-exercises/chp7-applicative-programming/ex-07-10-keyboard-exercise.lisp | ; file: ex-07-10-keyboard-exercise.lisp
; author: Jon David
; date: Sunday, August 03, 2014
; description:
; exercise 7.10 - In this exercise we will write a program to
; transpose a song from one key to another. In order to manipulate
; notes more efficiently, we will translate them into numbers. Here
; is the... | 5,488 | Common Lisp | .lisp | 136 | 37.610294 | 70 | 0.664353 | joncdavid/touretzky-lisp-exercises | 3 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:27:44 AM (Europe/Amsterdam) | f9080a978da9976d6f31a89fd05da7dd42a2413377461e666b82bf19f0c3d0c4 | 17,079 | [
-1
] |
17,080 | ex-07-30.lisp | joncdavid_touretzky-lisp-exercises/chp7-applicative-programming/ex-07-30.lisp | ; file: ex-07-30.lisp
; author: Jon David
; date: Saturday, August 09, 2014
; description:
; exercise 7.30 - Recall the English-French dictionary we stored in
; the global variable WORDS earlier in the chapter. Given this
; dictionary plus the list or corresponding Spanish words (UNO DOS
; TRES QUATRO CINCO), w... | 1,056 | Common Lisp | .lisp | 30 | 32.4 | 73 | 0.72549 | joncdavid/touretzky-lisp-exercises | 3 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:27:44 AM (Europe/Amsterdam) | b9eda7d0fe52c5cb3ca5612533e4002536b73e4add356f20dbab908140fd8e3c | 17,080 | [
-1
] |
17,081 | ex-07-16.lisp | joncdavid_touretzky-lisp-exercises/chp7-applicative-programming/ex-07-16.lisp | ; file: ex-07-16.lisp
; author: Jon David
; date: Thursday, August 07, 2014
; description:
; exercise 7.16 - Suppose we had a list of sets:
; ((A B C) (C D A) (F B D) (G))
;
; that we wanted to collapse into one big set. If we use APPEND for
; for our reducing function, the result won't be a true set, because
... | 763 | Common Lisp | .lisp | 19 | 38.473684 | 70 | 0.675639 | joncdavid/touretzky-lisp-exercises | 3 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:27:44 AM (Europe/Amsterdam) | 6d7997644b45671ff6680aa10ae4888a29cbe6f2ad734de413633ca9eebb6b37 | 17,081 | [
-1
] |
17,082 | ex-07-15-keyboard-exercise.lisp | joncdavid_touretzky-lisp-exercises/chp7-applicative-programming/ex-07-15-keyboard-exercise.lisp | ; file: ex-07-15.lisp
; author: Jon David
; date: Wednesday, August 06, 2014
; description:
; exercise 7.15 - In this keyboard exercise we will manipulate
; playing cards with applicative operators. A card will be
; represented by a list of form (rank suit), for example (ACE
; SPADES) or (2 CLUBS). A hand will ... | 5,126 | Common Lisp | .lisp | 140 | 33.7 | 70 | 0.679386 | joncdavid/touretzky-lisp-exercises | 3 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:27:44 AM (Europe/Amsterdam) | 3fe0da443cae822e8c72956d234f77091ab86365575d9feecf1ac6cc437f1a69 | 17,082 | [
-1
] |
17,083 | ex-07-09.lisp | joncdavid_touretzky-lisp-exercises/chp7-applicative-programming/ex-07-09.lisp | ; file: ex-07-09.lisp
; author: Jon David
; date: Sunday, August 03, 2014
; description:
; exercise 7.9 - Write a function FIND-NESTED that returns the first
; element of a list that is itself a non-NIL list.
(defun find-nested (list)
(find-if #'(lambda (n)
(and (listp n) (not (null n))))
list))
(d... | 475 | Common Lisp | .lisp | 15 | 28.4 | 70 | 0.646667 | joncdavid/touretzky-lisp-exercises | 3 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:27:44 AM (Europe/Amsterdam) | 39d26e2474d4beed23fec3f61534eb54d238f103e5d93305e382312b92f80c11 | 17,083 | [
-1
] |
17,084 | ex-07-13.lisp | joncdavid_touretzky-lisp-exercises/chp7-applicative-programming/ex-07-13.lisp | ; file: ex-07-13.lisp
; author: Jon David
; date: Monday, August 04, 2014
; description:
; exercise 7.13 - Write a function that picks from a list of lists
; those of exactly length two.
(defun pick-nested-lists-size-2 (list)
(remove-if-not #'(lambda (n)
(and (listp n) (equal 2 (length n))))
list))
(de... | 515 | Common Lisp | .lisp | 15 | 31.533333 | 68 | 0.642424 | joncdavid/touretzky-lisp-exercises | 3 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:27:44 AM (Europe/Amsterdam) | b23efb8888d0b9bd2af9c45e82c017559d09fdb22d4e2ed705a3e6703285041c | 17,084 | [
-1
] |
17,085 | ex-07-17.lisp | joncdavid_touretzky-lisp-exercises/chp7-applicative-programming/ex-07-17.lisp | ; file: ex-07-17.lisp
; author: Jon David
; date: Thursday, August 07, 2014
; description:
; exercise 7.17 - Write a funciton that, given a list of lists,
; returns the total length of all the lists. This problem can be
; solved two different ways.
(defun num-elements (list-of-lists)
(reduce #'+ (mapcar #'leng... | 509 | Common Lisp | .lisp | 14 | 34.357143 | 66 | 0.687627 | joncdavid/touretzky-lisp-exercises | 3 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:27:44 AM (Europe/Amsterdam) | f5a3155042de7c4c9bd48cffdf06d85b79a8782186591af49067c6486d9ced43 | 17,085 | [
-1
] |
17,086 | ex-07-19.lisp | joncdavid_touretzky-lisp-exercises/chp7-applicative-programming/ex-07-19.lisp | ; file: ex-07-19.lisp
; author: Jon David
; date: Thursday, August 07, 2014
; description:
; exercise 7.19 - Write a function ALL-ODD that returns T if every
; element of a list of numbers is odd.
(defun all-odd (numbers-list)
(every #'oddp numbers-list))
(defun ut-all-odd ()
(let* ((test-list '(-1 1 3 5 7))
... | 398 | Common Lisp | .lisp | 13 | 28.461538 | 69 | 0.678851 | joncdavid/touretzky-lisp-exercises | 3 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:27:44 AM (Europe/Amsterdam) | 6b72a1f89012454fcaa6d6ec48ccf3817d5c05163b0691538493883abfef7b5c | 17,086 | [
-1
] |
17,087 | ex-07-05.lisp | joncdavid_touretzky-lisp-exercises/chp7-applicative-programming/ex-07-05.lisp | ; file: ex-07-05.lisp
; author: Jon David
; date: Sunday, August 03, 2014
; description:
; exercise 7.5 - Write a lambda expression to subtract seven from
; a number.
(defun ut-ex-07-05 ()
(let* ((test-list '(0 1 2 3 4 5 6 7 8))
(actual (mapcar #'(lambda (n) (- n 7)) test-list))
(expected '(-7 -6 -5 -4 -3 -2... | 361 | Common Lisp | .lisp | 11 | 30.818182 | 67 | 0.621777 | joncdavid/touretzky-lisp-exercises | 3 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:27:44 AM (Europe/Amsterdam) | b52c118a6908ae2183395bc92451c42f273fcd2b125a1de86411aa2776ac428b | 17,087 | [
-1
] |
17,088 | ex-07-06.lisp | joncdavid_touretzky-lisp-exercises/chp7-applicative-programming/ex-07-06.lisp | ; file: ex-07-06.lisp
; author: Jon David
; date: Sunday, August 03, 2014
; description:
; exercise 7.6 - Write a lambda expression that returns T if its
; input is T or NIL, but NIL for any other input.
(defun ut-ex-07-06 ()
(let* ((test-list '(t nil 'a '(a) '(a b) '((a) (b))))
(actual (mapcar #'(lambda (n)
... | 443 | Common Lisp | .lisp | 13 | 31.230769 | 66 | 0.619159 | joncdavid/touretzky-lisp-exercises | 3 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:27:44 AM (Europe/Amsterdam) | fccf4af81dc98c95805d17e069a0434beec182a4a713ada75151b03e6d57fb89 | 17,088 | [
-1
] |
17,089 | ex-07-26.lisp | joncdavid_touretzky-lisp-exercises/chp7-applicative-programming/ex-07-26.lisp | ; file: ex-07-26.lisp
; author: Jon David
; date: Thursday, August 07, 2014
; description:
; exercise 7.26 - Show how to write FIND-IF given REMOVE-IF-NOT.
(defun ut-ex-07-26 ()
(let* ((test-list '(-2 0 2 4 5 6))
(actual (find-if #'oddp test-list))
(expected (car (remove-if-not #'oddp test-list))))
(print t... | 399 | Common Lisp | .lisp | 13 | 28.076923 | 66 | 0.656331 | joncdavid/touretzky-lisp-exercises | 3 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:27:44 AM (Europe/Amsterdam) | 6334ab5faf0d5397855014791499d6b5f3610f9c338338a7bb4434737cdd462e | 17,089 | [
-1
] |
17,090 | ex-07-21.lisp | joncdavid_touretzky-lisp-exercises/chp7-applicative-programming/ex-07-21.lisp | ; file: ex-07-21.lisp
; author: Jon David
; date: Thursday, August 07, 2014
; description:
; exercise 7.21 - Write a function NOT-ALL-ODD that returns T if not
; every element of a list of numbers is odd.
(defun not-all-odd (numbers-list)
(not (every #'oddp numbers-list)))
(defun ut-not-all-odd ()
(let* ((test... | 426 | Common Lisp | .lisp | 13 | 30.461538 | 70 | 0.681373 | joncdavid/touretzky-lisp-exercises | 3 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:27:44 AM (Europe/Amsterdam) | 9e27e5d64e650e735c2e0d04238f93c11648b87bf93dffa9a4f833c9c771216e | 17,090 | [
-1
] |
17,091 | ex-07-07.lisp | joncdavid_touretzky-lisp-exercises/chp7-applicative-programming/ex-07-07.lisp | ; file: ex-07-07.lisp
; author: Jon David
; date: Sunday, August 03, 2014
; description:
; exercise 7.7 - Write a function that takes a list such as
; (UP DOWN UP UP) and "flips" each element, returning
; (DOWN UP DOWN DOWN). Your function should include a lambda
; expression that knows how to flip an individua... | 694 | Common Lisp | .lisp | 21 | 30.238095 | 62 | 0.665172 | joncdavid/touretzky-lisp-exercises | 3 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:27:44 AM (Europe/Amsterdam) | d2dbad10be027d115f676205e429aaef24d6db948309f1eae49138625b28d1a0 | 17,091 | [
-1
] |
17,092 | ex-07-08.lisp | joncdavid_touretzky-lisp-exercises/chp7-applicative-programming/ex-07-08.lisp | ; file: ex-07-08.lisp
; author: Jon David
; date: Sunday, August 03, 2014
; description:
; exercise 7.8 - Write a function that takes two inputs, X and K, and
; returns the first number in the list X that is roughly equal to K.
; Let's say that "roughly equal" means no less than K-10 and no more
; than K+10.
;... | 675 | Common Lisp | .lisp | 20 | 30.95 | 71 | 0.626728 | joncdavid/touretzky-lisp-exercises | 3 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:27:44 AM (Europe/Amsterdam) | 9cf553a91b742160b5d65c74cf3fbe04512074a40c6db105288b49a0d55c5531 | 17,092 | [
-1
] |
17,093 | ex-07-22.lisp | joncdavid_touretzky-lisp-exercises/chp7-applicative-programming/ex-07-22.lisp | ; file: ex-07-22.lisp
; author: Jon David
; date: Thursday, August 07, 2014
; description:
; exercise 7.22 - Write a function NOT-NONE-ODD that returns T if it
; is not the case that a list of numbers contains no odd elements.
(defun not-none-odd (numbers-list)
(not (every #'evenp numbers-list)))
(defun ut-not-n... | 455 | Common Lisp | .lisp | 13 | 32.615385 | 70 | 0.690367 | joncdavid/touretzky-lisp-exercises | 3 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:27:44 AM (Europe/Amsterdam) | 9b28c5dd9971b29bd95b1f48f3fe9e481ee40337d2a844d09b93801ebffe2530 | 17,093 | [
-1
] |
17,094 | ex-07-20.lisp | joncdavid_touretzky-lisp-exercises/chp7-applicative-programming/ex-07-20.lisp | ; file: ex-07-20.lisp
; author: Jon David
; date: Thursday, August 07, 2014
; description:
; exercise 7.20 - Write a function NONE-ODD that returns T if every
; element of a list of numbers is not odd.
(defun none-odd (numbers-list)
(every #'evenp numbers-list))
(defun ut-none-odd ()
(let* ((test-list '(-2 0 2... | 409 | Common Lisp | .lisp | 13 | 29.307692 | 69 | 0.684478 | joncdavid/touretzky-lisp-exercises | 3 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:27:44 AM (Europe/Amsterdam) | d04aa88b345f6589f561e9c5e738f445b069ca304e0049e8e1b4e49c8bdab181 | 17,094 | [
-1
] |
17,095 | ex-07-18.lisp | joncdavid_touretzky-lisp-exercises/chp7-applicative-programming/ex-07-18.lisp | ; file: ex-07-18.lisp
; author: Jon David
; date: Thursday, August 07, 2014
; description:
; exercise 7.18 - (REDUCE #'+ NIL) returns 0, but (REDUCE #'* NIL)
; returns 1. Why do you think this is?
;
; answer:
; NIL is equivalent to an empty list. In addition, adding zero to
; anything is the identity property. ... | 460 | Common Lisp | .lisp | 12 | 37.333333 | 69 | 0.727679 | joncdavid/touretzky-lisp-exercises | 3 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:27:44 AM (Europe/Amsterdam) | 662349581886e02b8ee35f669ae28b2731e5460709f70249c3ae496370a0ca76 | 17,095 | [
-1
] |
17,096 | ex-06-11.lisp | joncdavid_touretzky-lisp-exercises/chp6-list-data-structures/ex-06-11.lisp | ; file: ex-06-11.lisp
; author: Jon David
; date: Saturday, July 26, 2014
; description:
; exercise 6.11 - Write a function MAKE-PALINDROME that makes a
; palindrome out of a list, for example, given (YOU AND ME) as input
; it should return (YOU AND ME ME AND YOU).
(load "ex-06-10.lisp")
(defun make-palindrome ... | 632 | Common Lisp | .lisp | 17 | 35.176471 | 70 | 0.622951 | joncdavid/touretzky-lisp-exercises | 3 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:27:44 AM (Europe/Amsterdam) | 0c2ab8b0866e0b56a4a9820327bcbd44a88f2195857c66d735bae2fca22bcd8b | 17,096 | [
-1
] |
17,097 | ex-06-18.lisp | joncdavid_touretzky-lisp-exercises/chp6-list-data-structures/ex-06-18.lisp | ; file: ex-06-18.lisp
; author: Jon David
; date: Saturday, July 26, 2014
; description:
; exercise 6.18 - Write a function ADD-VOWELS that takes a set of
; letters as input and adds the vowels (A E I O U) to the set. For
; example, calling ADD-VOWELS on the set (X A E Z) should produce
; the set (X A E Z I O U... | 872 | Common Lisp | .lisp | 24 | 34.208333 | 70 | 0.614472 | joncdavid/touretzky-lisp-exercises | 3 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:27:44 AM (Europe/Amsterdam) | f36f40ceca412ec7af0b703290da241e00aa4b75b61aac1d63611c076adf6073 | 17,097 | [
-1
] |
17,098 | ex-06-42.lisp | joncdavid_touretzky-lisp-exercises/chp6-list-data-structures/ex-06-42.lisp | ; file: ex-06-42.lisp
; author: Jon David
; date: Sunday, July 27, 2014
; description:
; exercise 6.42 - Write a function called ROYAL-WE that changes
; every occurence of the symbol I in a list to the symbol WE.
; Calling this function on the list (IF I LEARN LISP I WILL BE
; PLEASED) should return the list (I... | 604 | Common Lisp | .lisp | 16 | 35.75 | 65 | 0.702055 | joncdavid/touretzky-lisp-exercises | 3 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:27:44 AM (Europe/Amsterdam) | d3331c0e9314ca4aeff4c190a64449a20399006ba4f66d75e4da8965111719e9 | 17,098 | [
-1
] |
17,099 | ex-06-25.lisp | joncdavid_touretzky-lisp-exercises/chp6-list-data-structures/ex-06-25.lisp | ; file: ex-06-25.lisp
; author: Jon David
; date: Saturday, July 26, 2014
; description:
; exercise 6.25 - A set X is a proper subset of a set Y if X
; is a subset of Y but not equal to Y. Thurs, (A C) is a proper
; subset of (C A B). (A B C) is a subset of (C A B), but not a
; proper subset of it. Write the P... | 738 | Common Lisp | .lisp | 19 | 36.578947 | 70 | 0.580645 | joncdavid/touretzky-lisp-exercises | 3 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:27:44 AM (Europe/Amsterdam) | 81c129787c7cefcd80e0fbcaf69ce5bb9d9caacba4af6c6bf4fdce39adba5750 | 17,099 | [
-1
] |
17,100 | ex-06-09.lisp | joncdavid_touretzky-lisp-exercises/chp6-list-data-structures/ex-06-09.lisp | ; file: ex-06-09.lisp
; author: Jon David
; date: Saturday, July 26, 2014
; description:
; exercise 6.9 - What primitive function does the following
; reduce to?
;
; answer: MYSTERY is equivalent to CAR.
(defun mystery (x)
(first (last (reverse x))))
;============================================================... | 538 | Common Lisp | .lisp | 17 | 29.941176 | 70 | 0.597679 | joncdavid/touretzky-lisp-exercises | 3 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:27:44 AM (Europe/Amsterdam) | 55fe0259b2fac50696a85180a71466e1cf078e932e8c6254ee244f26d9524d12 | 17,100 | [
-1
] |
17,101 | ex-06-10.lisp | joncdavid_touretzky-lisp-exercises/chp6-list-data-structures/ex-06-10.lisp | ; file: ex-06-10.lisp
; author: Jon David
; date: Saturday, July 26, 2014
; description:
; exercise 6.10 - A palindrome is a sequence that reads the same
; forwards and backwards. The list (A B C D C B A) is a palindrome;
; (A B C A B C) is not. Write a function PALINDROMEP that returns T
; if its input is a pa... | 598 | Common Lisp | .lisp | 15 | 37.866667 | 70 | 0.599309 | joncdavid/touretzky-lisp-exercises | 3 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:27:44 AM (Europe/Amsterdam) | b46bc088d9befbc16e1eb7895a64a52823c4d38500529f2a9a3f98fedbe08355 | 17,101 | [
-1
] |
17,102 | ex-06-02.lisp | joncdavid_touretzky-lisp-exercises/chp6-list-data-structures/ex-06-02.lisp | ; file: ex-06-02.lisp
; author: Jon David
; date: Saturday, July 26, 2014
; description:
; exercise 6.3 - What is the value of (NTH 3 '(A B C . D)
; and why?
;
; solution:
; (NTH 3 '(A B C . D)) produces an error. It takes three CDRs
; of its input, which produces the symbol D. Taking the CAR
; of D then cau... | 358 | Common Lisp | .lisp | 11 | 31.545455 | 63 | 0.665706 | joncdavid/touretzky-lisp-exercises | 3 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:27:44 AM (Europe/Amsterdam) | 3b8732bef3d7f1df8f76b83175a3edb1369e241122ca7a0342990aafb1c2e66e | 17,102 | [
-1
] |
17,103 | ex-06-40.lisp | joncdavid_touretzky-lisp-exercises/chp6-list-data-structures/ex-06-40.lisp | ; file: ex-06-40.lisp
; author: Jon David
; date: Sunday, July 27, 2014
; description:
; exercise 6.40 - Show how to transform the list (A B C D) into a
; table so that the ASSOC function using the table gives the same
; result as MEMBER using the list.
(setf x-list '(a b c d))
(setf x-table '((A B C D)
(B C D... | 577 | Common Lisp | .lisp | 17 | 31 | 67 | 0.624101 | joncdavid/touretzky-lisp-exercises | 3 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:27:44 AM (Europe/Amsterdam) | bdcbb3c2af99e9b543046439d4f1f6d468399fa05a3ec45be08dd16017d369ca | 17,103 | [
-1
] |
17,104 | ex-06-07.lisp | joncdavid_touretzky-lisp-exercises/chp6-list-data-structures/ex-06-07.lisp | ; file: ex-06-07.lisp
; author: Jon David
; date: Saturday, July 26, 2014
; description:
; exercise 6.7 - Use REVERSE to write a NEXT-TO-LAST function that
; returns the next-to-last element of a list. Write another version
; using NTH.
(defun next-to-last-a (list)
(cadr (reverse list)))
(defun next-to-last... | 678 | Common Lisp | .lisp | 20 | 31.5 | 70 | 0.585253 | joncdavid/touretzky-lisp-exercises | 3 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:27:44 AM (Europe/Amsterdam) | 94c1412b6a6462bdf7e307e04a204dc4136143f3044b2caf2c44e85c7e5ae8ce | 17,104 | [
-1
] |
17,105 | ex-06-24.lisp | joncdavid_touretzky-lisp-exercises/chp6-list-data-structures/ex-06-24.lisp | ; file: ex-06-24.lisp
; author: Jon David
; date: Saturday, July 26, 2014
; description:
; exercise 6.24 - Sets are said to be equal if they contain exactly
; the same elements. Order does not matter in a setm so the sets
; (RED BLUE GREEN) and (GREEN BLUE RED) are considered equal.
; However, the EQUAL predica... | 909 | Common Lisp | .lisp | 21 | 40.571429 | 70 | 0.608597 | joncdavid/touretzky-lisp-exercises | 3 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:27:44 AM (Europe/Amsterdam) | ee7f720f8edf64b3035b6933659f9ef4ad657f008717b973b8baf2778c6bf269 | 17,105 | [
-1
] |
17,106 | ex-06-30.lisp | joncdavid_touretzky-lisp-exercises/chp6-list-data-structures/ex-06-30.lisp | ; file: ex-06-30.lisp
; author: Jon David
; date: Saturday, July 26, 2014
; description:
; exercise 6.30 - Make a table called BOOKS of five books and their
; authors. The first entry might be (WAR-AND-PEACE LEO-TOLSTOY).
; Defines the BOOKS table.
(setf BOOKS '((war-and-peace leo-tolstoy)
(gentle-introduct... | 464 | Common Lisp | .lisp | 12 | 35.083333 | 69 | 0.712695 | joncdavid/touretzky-lisp-exercises | 3 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:27:44 AM (Europe/Amsterdam) | abf1f0a5e31a5fec66ea8a719c60ee13584ef122847f5cfcc77ce9859d27fac9 | 17,106 | [
-1
] |
17,107 | ex-06-26.lisp | joncdavid_touretzky-lisp-exercises/chp6-list-data-structures/ex-06-26.lisp | ; file: ex-06-26.lisp
; author: Jon David
; date: Saturday, July 26, 2014
; description:
; exercise 6.26 - We are going to write a program that compare the
; descriptions of two objects and tells how many features they have
; in common. The descriptions will be represented as a list of
; features, with the symb... | 3,268 | Common Lisp | .lisp | 83 | 36.807229 | 70 | 0.690852 | joncdavid/touretzky-lisp-exercises | 3 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:27:44 AM (Europe/Amsterdam) | 2439fe5e7eb19bf6f0853736c066ef007d042319f48b0c6f9c009bfede6c1d97 | 17,107 | [
-1
] |
17,108 | ex-06-31.lisp | joncdavid_touretzky-lisp-exercises/chp6-list-data-structures/ex-06-31.lisp | ; file: ex-06-31.lisp
; author: Jon David
; date: Sunday, July 27, 2014
; description:
; exercise 6.31 - Write the function WHO-WROTE that takes the name of
; a book as input and returns the book's author.
(load "ex-06-30.lisp")
(defun who-wrote (book-name)
(cadr (assoc book-name BOOKS)))
| 301 | Common Lisp | .lisp | 9 | 31.666667 | 71 | 0.714286 | joncdavid/touretzky-lisp-exercises | 3 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:27:44 AM (Europe/Amsterdam) | 17df229eb382815b971094d48b4504df7861dd5c007629e4d1005c571b67316d | 17,108 | [
-1
] |
17,109 | ex-06-37.lisp | joncdavid_touretzky-lisp-exercises/chp6-list-data-structures/ex-06-37.lisp | ; file: ex-06-37.lisp
; author: Jon David
; date: Sunday, July 27, 2014
; description:
; exercise 6.37 - ROTATE-LEFT and ROTATE-RIGHT are functions that
; rotate the elements of a list. (ROTATE-LEFT '(A B C D E)) returns
; (B C D E A), whereas ROTATE-RIGHT returns (E A B C D). Write
; these functions.
(defun r... | 785 | Common Lisp | .lisp | 23 | 31.695652 | 69 | 0.664011 | joncdavid/touretzky-lisp-exercises | 3 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:27:44 AM (Europe/Amsterdam) | 24a52ed1e4aea52d9766aa875d17f23a880f47864ff740d676cd85b14a83c89a | 17,109 | [
-1
] |
17,110 | ex-06-08.lisp | joncdavid_touretzky-lisp-exercises/chp6-list-data-structures/ex-06-08.lisp | ; file: ex-06-08.lisp
; author: Jon David
; date: Saturday, July 26, 2014
; description:
; exercise 6.8 - Write a function MY-BUTLAST that returns a list
; with the last element removed. (MY-BUTLAST '(ROSES ARE RED))
; should return the list (ROSES ARE). (MY-BUTLAST '(G A G A))
; should return (G A G).
(defun ... | 630 | Common Lisp | .lisp | 17 | 35.235294 | 70 | 0.586885 | joncdavid/touretzky-lisp-exercises | 3 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:27:44 AM (Europe/Amsterdam) | e2b037dd1780100bdd7fd366481654f8603658fc1878ced977914eb6224219ed | 17,110 | [
-1
] |
17,111 | ex-06-41-keyboard-exercise.lisp | joncdavid_touretzky-lisp-exercises/chp6-list-data-structures/ex-06-41-keyboard-exercise.lisp | ; file: ex-06-41.lisp
; author: Jon David
; date: Sunday, July 27, 2014
; description:
; exercise 6.41 - If the table of rooms is already stored on the
; computer for you, load the file containing it. If not, you will
; have to type the table in as it appears in Figure 6-3 (pg. 188).
(setf ROOMS '((living-room
... | 5,441 | Common Lisp | .lisp | 136 | 35.786765 | 70 | 0.685806 | joncdavid/touretzky-lisp-exercises | 3 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:27:44 AM (Europe/Amsterdam) | da7ced869e7f4a82a90cb14a52bea2486f85c2443aa774f2d17407310e1aad33 | 17,111 | [
-1
] |
17,112 | ex-06-21.lisp | joncdavid_touretzky-lisp-exercises/chp6-list-data-structures/ex-06-21.lisp | ; file: ex-06-21.lisp
; author: Jon David
; date: Saturday, July 26, 2014
; description:
; exercise 6.21 - If set x is a subset of set y, then subtracting
; y from x should leave the empty set. Write MY-SUBSETP, a version
; of the SUBSETP predicate that returns T if its first input is a
; subset of its second i... | 556 | Common Lisp | .lisp | 15 | 35.666667 | 70 | 0.607076 | joncdavid/touretzky-lisp-exercises | 3 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:27:44 AM (Europe/Amsterdam) | 7173b6f790139fd0b9cad66a547f5d83dca0af69814f35d99d1e36e307dce19c | 17,112 | [
-1
] |
17,113 | ex-06-34.lisp | joncdavid_touretzky-lisp-exercises/chp6-list-data-structures/ex-06-34.lisp | ; file: ex-06-34.lisp
; author: Jon David
; date: Sunday, July 27, 2014
; description:
; exercise 6.34 - Here is a table of states and some of their
; cities stored in the global variable ATLAS:
;
; (setf ATLAS '((pennsylvania pittsburgh)
; (new-jersey newark)
; (pennsylvania johns... | 914 | Common Lisp | .lisp | 23 | 37.913043 | 70 | 0.670429 | joncdavid/touretzky-lisp-exercises | 3 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:27:44 AM (Europe/Amsterdam) | afa257c43201ec09a0e0af492cfc299f761c13e30f1072fb00935fdb2b71a6c9 | 17,113 | [
-1
] |
17,114 | ex-06-15.lisp | joncdavid_touretzky-lisp-exercises/chp6-list-data-structures/ex-06-15.lisp | ; file: ex-06-15.lisp
; author: Jon David
; date: Saturday, July 26, 2014
; description:
; exercise 6.15 - We can use MEMBER to write a predicate that
; returns a true value if a sentence contains the word "the".
;
; (defun contains-the-p (sentence)
; (member 'the sentence))
;
; Suppose we instead want a ... | 1,753 | Common Lisp | .lisp | 40 | 41.025 | 70 | 0.676833 | joncdavid/touretzky-lisp-exercises | 3 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:27:44 AM (Europe/Amsterdam) | 60ccdd8f78ce3b0b8f0466900ea89ba1c8342023c1f28e9c2311e2cc08897d52 | 17,114 | [
-1
] |
17,115 | ex-06-01.lisp | joncdavid_touretzky-lisp-exercises/chp6-list-data-structures/ex-06-01.lisp | ; file: ex-06-01.lisp
; author: Jon David
; date: Saturday, July 26, 2014
; description:
; exercise 6.1 - Why is (NTH 4 '(A B C)) equal to NIL?
;
; solution:
; (NTH 4 '(A B C)) is NIL because NTH4 requires four CDRs
; on a 3-element list.
| 245 | Common Lisp | .lisp | 9 | 26.222222 | 59 | 0.65678 | joncdavid/touretzky-lisp-exercises | 3 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:27:44 AM (Europe/Amsterdam) | e10daf24acab8f753f9d14d7f56e61af148e810b6147cfa63c02ee0af53b8e3e | 17,115 | [
-1
] |
17,116 | ex-06-12.lisp | joncdavid_touretzky-lisp-exercises/chp6-list-data-structures/ex-06-12.lisp | ; file: ex-06-12.lisp
; author: Jon David
; date: Saturday, July 26, 2014
; description:
; exercise 6.12 - Does MEMBER have to copy its input to produce its
; results? Explain your reasoning.
;
; answer:
; No because it only has to return NIL or the cons cell of the first
; instance.
| 293 | Common Lisp | .lisp | 10 | 28.3 | 70 | 0.724382 | joncdavid/touretzky-lisp-exercises | 3 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:27:44 AM (Europe/Amsterdam) | 324b0c53d01ba3cd1965cf1f79f47e2e83854a74d3abc74ea2e50646850ef582 | 17,116 | [
-1
] |
17,117 | ex-06-06.lisp | joncdavid_touretzky-lisp-exercises/chp6-list-data-structures/ex-06-06.lisp | ; file: ex-06-06.lisp
; author: Jon David
; date: Saturday, July 26, 2014
; description:
; exercise 6.6. - Use the LAST function to write a function called
; LAST_ELEMENT that returns the last element of a list instead of
; the last cons cell. Write another version of LAST-ELEMENT using
; REVERSE instead of la... | 961 | Common Lisp | .lisp | 28 | 32.035714 | 70 | 0.62635 | joncdavid/touretzky-lisp-exercises | 3 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:27:44 AM (Europe/Amsterdam) | 775a3d6306a843e25e02f1378ac69f00cc865cc1f18527911937f0a2af2421d3 | 17,117 | [
-1
] |
17,118 | ex-06-36.lisp | joncdavid_touretzky-lisp-exercises/chp6-list-data-structures/ex-06-36.lisp | ; file: ex-06-36.lisp
; author: Jon David
; date: Sunday, July 27, 2014
; description:
; exercise 6.36 - Write a function to swap the first and last
; elements of any list. (SWAP-FIRST-LAST '(YOU CANT BUY LOVE))
; should return (LOVE CANT BUY YOU).
(defun swap-first-last (list)
(let* ((but-last (reverse (cdr (... | 625 | Common Lisp | .lisp | 18 | 32.111111 | 64 | 0.676667 | joncdavid/touretzky-lisp-exercises | 3 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:27:44 AM (Europe/Amsterdam) | a3595f0277b21f250761a3dd5d8e03b907b5f969404c3455c8ffd95f0176d36b | 17,118 | [
-1
] |
17,119 | ex-06-35-keyboard-exercise.lisp | joncdavid_touretzky-lisp-exercises/chp6-list-data-structures/ex-06-35-keyboard-exercise.lisp | ; file: ex-06-35.lisp
; author: Jon David
; date: Sunday, July 27, 2014
; description:
; exercise 6.35 - In this problem we will simulate the behavior of
; a very simple-minded creature, Nerdus Americanis (also known as
; Computerus Hackerus). This create hash only five states:
; Sleeping
; Eating
; W... | 2,381 | Common Lisp | .lisp | 51 | 44.666667 | 70 | 0.740086 | joncdavid/touretzky-lisp-exercises | 3 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:27:44 AM (Europe/Amsterdam) | 698bdc63175f96a318e9e79041706d7ebf753ca1cf9161ed0cbcc44d23b891bb | 17,119 | [
-1
] |
17,120 | ex-04-20.lisp | joncdavid_touretzky-lisp-exercises/chp4-conditionals/ex-04-20.lisp | ; file: ex-04-20.lisp
; author: Jon David
; date: Saturday, July 12, 2014
; description:
; exercise 4.20 - Write a version of the COMPARE function using IF
; instead of COND. Also write a version using AND and OR.
;
; Note:
; COMPARE function returns NUMBERS-ARE-THE-SAME, FIRST-IS-BIGGER,
; and FIRST-IS-SMA... | 586 | Common Lisp | .lisp | 18 | 29.944444 | 68 | 0.666667 | joncdavid/touretzky-lisp-exercises | 3 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:27:44 AM (Europe/Amsterdam) | 3b583b701cdcbf6ef55de0940dac960501f6b3c55e4d811273d671f04a2a5d38 | 17,120 | [
-1
] |
17,121 | ex-04-17.lisp | joncdavid_touretzky-lisp-exercises/chp4-conditionals/ex-04-17.lisp | ; file: ex-04-17.lisp
; author: Jon David
; date: Saturday, July 12, 2014
; description:
; exercise 4.17 - Write a predicate that returns T if the first
; input is either BOY or GIRL and the second is CHILD,
; or if the first input is either MAN or WOMAN and the second
; input is ADULT.
(defun gender-age-p (ge... | 522 | Common Lisp | .lisp | 13 | 38 | 65 | 0.691089 | joncdavid/touretzky-lisp-exercises | 3 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:27:44 AM (Europe/Amsterdam) | eca61f86ef46137273bfa460f130bfcf786f53cb4593fed861d5384f8325cc97 | 17,121 | [
-1
] |
17,122 | ex-04-03.lisp | joncdavid_touretzky-lisp-exercises/chp4-conditionals/ex-04-03.lisp | ; file: ex-04-03.lisp
; author: Jon David
; date: Saturday, July 12, 2014
; description:
; exercise 4.3 - Recall the primitive function NOT: It returns NIL
; for a true input and T for a false one. Suppose Lisp didn't have
; a NOT primitive. Show how to write NOT using just IF and
; constants (no other functi... | 389 | Common Lisp | .lisp | 10 | 37.6 | 69 | 0.71164 | joncdavid/touretzky-lisp-exercises | 3 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:27:44 AM (Europe/Amsterdam) | 1077612d73ee8c48157bd921bbbae2cdcac04ef8cc9ab7bb978f1b2dedbde9c1 | 17,122 | [
-1
] |
17,123 | ex-04-16.lisp | joncdavid_touretzky-lisp-exercises/chp4-conditionals/ex-04-16.lisp | ; file: ex-04-16.lisp
; author: Jon David
; date: Saturday, July 12, 2014
; description:
; exercise 4.16 - Write a function that:
; squares a number if it is odd and positive,
; doubles if it is odd and negative,
; and otherwise divides the number by 2.
(defun ex-4-16 (x)
(cond ((and (oddp x) (> x 0)) (* x x... | 378 | Common Lisp | .lisp | 12 | 29.583333 | 47 | 0.623955 | joncdavid/touretzky-lisp-exercises | 3 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:27:44 AM (Europe/Amsterdam) | 93a511596325de359bb832dcbb0bb8d40f91292964666b3d628418ad94ad6e5d | 17,123 | [
-1
] |
17,124 | ex-04-14.lisp | joncdavid_touretzky-lisp-exercises/chp4-conditionals/ex-04-14.lisp | ; file: ex-04-14.lisp
; author: Jon David
; date: Saturday, July 12, 2014
; description:
; exercise 4.14 - What results do the following expressions
; produce? Read the evaluation rules for AND and OR carefully
; before answering.
;
; Evaluation rule for AND: return nil if any clause is nil,
; otherwise retu... | 725 | Common Lisp | .lisp | 23 | 30.391304 | 65 | 0.680973 | joncdavid/touretzky-lisp-exercises | 3 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:27:44 AM (Europe/Amsterdam) | 073e47c0a7b808b07dd64a1d0aaf610762fd2813a5b2da70f6e432f43a9dcb9a | 17,124 | [
-1
] |
17,125 | ex-04-01.lisp | joncdavid_touretzky-lisp-exercises/chp4-conditionals/ex-04-01.lisp | ; file: ex-04-01.lisp
; author: Jon David
; date: Saturday, July 12, 2014
; description:
; exercise 4.1 - Write a function MAKE-EVEN that makes an odd number
; even by adding one to it. If the input to MAKE-EVEN is already
; even, it should be returned unchanged.
(defun make-even (n)
(if (oddp n) (+ n 1) n))
| 320 | Common Lisp | .lisp | 9 | 34.222222 | 70 | 0.696774 | joncdavid/touretzky-lisp-exercises | 3 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:27:44 AM (Europe/Amsterdam) | 22339a1e089cbe80a93a77dc543544a8a544e0fe5ee58524a925e0389455d0ae | 17,125 | [
-1
] |
17,126 | ex-04-35.lisp | joncdavid_touretzky-lisp-exercises/chp4-conditionals/ex-04-35.lisp | ; file: ex-04-35.lisp
; author: Jon David
; date: Saturday, July 12, 2014
; description:
; exercise 4.35 - Write down the DeMorgan equations for the
; three-input versions of AND and OR.
;
; Review (page 134):
; (and x y) = (not (or (not x) (not y)))
; "If x and y are true, then neither is x false nor is y fals... | 1,319 | Common Lisp | .lisp | 36 | 35.277778 | 70 | 0.650273 | joncdavid/touretzky-lisp-exercises | 3 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:27:44 AM (Europe/Amsterdam) | cb38951b952fd2580d6633fe4e4cecb4b152ac195bc8e18583917f1da82efbf5 | 17,126 | [
-1
] |
17,127 | ex-04-29.lisp | joncdavid_touretzky-lisp-exercises/chp4-conditionals/ex-04-29.lisp | ; file: ex-04-29.lisp
; author: Jon David
; date: Saturday, July 12, 2014
; description:
; exercise 4.29 - Write versions of LOGICAL-AND using IF and COND
; instead of AND.
(defun logical-and-if (x y)
(if x (if y t)))
(defun logical-and-cond (x y)
(cond (x (cond (y t)))))
| 284 | Common Lisp | .lisp | 10 | 26.7 | 67 | 0.667897 | joncdavid/touretzky-lisp-exercises | 3 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:27:44 AM (Europe/Amsterdam) | d9f0123902f99684f636642b155fa05493fc214ce367ad3679ac066371d79a5f | 17,127 | [
-1
] |
17,128 | ex-04-04.lisp | joncdavid_touretzky-lisp-exercises/chp4-conditionals/ex-04-04.lisp | ; file: ex-04-04.lisp
; author: Jon David
; date: Saturday, July 12, 2014
; description:
; exercise 4.4 - Write a function ORDERED that takes two numbers
; as input and makes a list of them in ascending order.
; (ORDERED 3 4) should return the list (3 4). (ORDERED 4 3) should
; also return (3 4), in other word... | 494 | Common Lisp | .lisp | 12 | 39.833333 | 69 | 0.697917 | joncdavid/touretzky-lisp-exercises | 3 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:27:44 AM (Europe/Amsterdam) | 21c6c6e365cda0fa5f810eb823ed50c7fcf25f25e9b978e44249b4bf02827a0f | 17,128 | [
-1
] |
17,129 | ex-04-05.lisp | joncdavid_touretzky-lisp-exercises/chp4-conditionals/ex-04-05.lisp | ; file: ex-04-05.lisp
; author: Jon David
; date: Saturday, July 12, 2014
; description:
; exercise 4.5 - For each of the following calls to COMPARE,
; write "1", "2", or "3" to indicate which clause of the
; COND will have a predicate that evaluates to true.
;
; solution
; --------... | 872 | Common Lisp | .lisp | 23 | 36.652174 | 66 | 0.612751 | joncdavid/touretzky-lisp-exercises | 3 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:27:44 AM (Europe/Amsterdam) | aa92823f3f2b3cca7ba8071a00be10a0da8c45fb67db6697099601fab9921816 | 17,129 | [
-1
] |
17,130 | ex-04-12.lisp | joncdavid_touretzky-lisp-exercises/chp4-conditionals/ex-04-12.lisp | ; file: ex-04-12.lisp
; author: Jon David
; date: Saturday, July 12, 2014
; description:
; exercise 4.12 - Write a function CYCLE that cyclically counts from
; 1 to 99. CYCLE called with an input of 1 should return 2, with
; and input of 2 should return 3, etc. With an input of 99, CYCLE
; should return 1. T... | 448 | Common Lisp | .lisp | 11 | 39.272727 | 70 | 0.695853 | joncdavid/touretzky-lisp-exercises | 3 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:27:44 AM (Europe/Amsterdam) | 3504a901f155eb5d3eb761cf823d781fa9248d454122c530df3b912a38663ee9 | 17,130 | [
-1
] |
17,131 | ex-04-10.lisp | joncdavid_touretzky-lisp-exercises/chp4-conditionals/ex-04-10.lisp | ; file: ex-04-10.lisp
; author: Jon David
; date: Saturday, July 12, 2014
; description:
; exercise 4.10 - Write a function CONSTRAIN that takes three
; inputs called X, MAX, and MIN. If X is less than MIN, then
; it should return MIN; if X is greater than MAX, it should
; return MAX. Otherwise, since X is be... | 692 | Common Lisp | .lisp | 21 | 30.619048 | 63 | 0.664168 | joncdavid/touretzky-lisp-exercises | 3 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:27:44 AM (Europe/Amsterdam) | 887315e3195e451f4ea057f6581186b9d94954961a8a45b4b52d616f57170b53 | 17,131 | [
-1
] |
17,132 | ex-04-37.lisp | joncdavid_touretzky-lisp-exercises/chp4-conditionals/ex-04-37.lisp | ; file: ex-04-37.lisp
; author: Jon David
; date: Saturday, July 12, 2014
; description:
; exercise 4.37 - NAND is called a logically complete function
; because we can construct all other boolean functions from
; various combinations of NAND. For example, here is a version
; of NOT called NOT2 constructed fro... | 2,536 | Common Lisp | .lisp | 63 | 38.047619 | 72 | 0.37627 | joncdavid/touretzky-lisp-exercises | 3 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:27:44 AM (Europe/Amsterdam) | 8e4769ddb8a01634a1a79b8d2e543533ab890d982dcfc2ec2c38f9b44ef84dc7 | 17,132 | [
-1
] |
17,133 | ex-04-23.lisp | joncdavid_touretzky-lisp-exercises/chp4-conditionals/ex-04-23.lisp | ; file: ex-04-23.lisp
; author: Jon David
; date: Saturday, July 12, 2014
; description:
; exercise 4.23 - The WHERE-IS function has four COND clauses, so
; WHERE-IS-2 needs three nested IFs. Suppose WHERE-IS had eight
; COND clauses. How many IFs would WHERE-IS-2 need? How many ORs
; would WHERE-IS-3 need? ... | 907 | Common Lisp | .lisp | 27 | 32.481481 | 68 | 0.668187 | joncdavid/touretzky-lisp-exercises | 3 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:27:44 AM (Europe/Amsterdam) | c2621de9b8ed11b0bef171d73316efa17a3081c79d8195c0ae03c19a5d59b277 | 17,133 | [
-1
] |
17,134 | ex-04-22.lisp | joncdavid_touretzky-lisp-exercises/chp4-conditionals/ex-04-22.lisp | ; file: ex-04-22.lisp
; author: Jon David
; date: Saturday, July 12, 2014
; description:
; exercise 4.22 - Use COND to write a predicate BOILINGP that takes
; two inputs, TEMP and SCALE, and returns T if the temperature is
; above the boiling point of water on the specified scale. If the
; scale is FAHRENHEIT,... | 766 | Common Lisp | .lisp | 17 | 43.117647 | 70 | 0.710067 | joncdavid/touretzky-lisp-exercises | 3 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:27:44 AM (Europe/Amsterdam) | a151a34b1d918a4ec95ad2fdc2417e51e38c9527c16f0c7f9088d65c0b01bae0 | 17,134 | [
-1
] |
17,135 | ex-04-09.lisp | joncdavid_touretzky-lisp-exercises/chp4-conditionals/ex-04-09.lisp | ; file: ex-04-09.lisp
; author: Jon David
; date: Saturday, July 12, 2014
; description:
; exercise 4.9 - Type in the following suspicious function
; definition:
;
; (defun make-odd (x)
; (cond (t x)
; ((not (oddp x)) (+ x 1))))
;
; The problem is the first test always evaluates to true. This
; ... | 477 | Common Lisp | .lisp | 18 | 25.166667 | 64 | 0.64693 | joncdavid/touretzky-lisp-exercises | 3 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:27:44 AM (Europe/Amsterdam) | d76b76d32eb2dc8312b11c3df360b5af56e6dd3b406e1187f0acc97553d7483e | 17,135 | [
-1
] |
17,136 | ex-04-38.lisp | joncdavid_touretzky-lisp-exercises/chp4-conditionals/ex-04-38.lisp | ; file: ex-04-38.lisp
; author: Jon David
; date: Saturday, July 12, 2014
; description:
; exercise 4.38 - Consider the NOR function (short for Not OR). Can
; you write versions of NOT, LOGICAL-AND, NAND, and LOGICAL-OR by
; putting NORs together?
;===============================================================... | 5,351 | Common Lisp | .lisp | 119 | 42.714286 | 70 | 0.392356 | joncdavid/touretzky-lisp-exercises | 3 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:27:44 AM (Europe/Amsterdam) | fca3e45d6fbda3f8b2a42899bad81724654d6612c16856f1424fe9f851252e49 | 17,136 | [
-1
] |
17,137 | ex-04-07.lisp | joncdavid_touretzky-lisp-exercises/chp4-conditionals/ex-04-07.lisp | ; file: ex-04-07.lisp
; author: Jon David
; date: Saturday, July 12, 2014
; description:
; exercise 4.7 - For each of the following COND expressions, tell whether
; the parenthesization is correct or incorrect. If incorrect, explain
; where the error lies.
; (cond (symbolp x) 'symbol
; (t 'not-a-symbol))
... | 722 | Common Lisp | .lisp | 22 | 31.5 | 75 | 0.656609 | joncdavid/touretzky-lisp-exercises | 3 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:27:44 AM (Europe/Amsterdam) | 49defc07294b7e1e330de616b26506bc6aaa54ec57987f238c7ca1da323291bc | 17,137 | [
-1
] |
17,138 | ex-04-06.lisp | joncdavid_touretzky-lisp-exercises/chp4-conditionals/ex-04-06.lisp | ; file: ex-04-06.lisp
; author: Jon David
; date: Saturday, July 12, 2014
; description:
; exercise 4.6 - Write a version of the absolute value function
; MY-ABS using COND instead of IF.
(defun my-abs (n)
(cond ((< n 0) (- n))
(t n)))
| 247 | Common Lisp | .lisp | 9 | 25.666667 | 65 | 0.662393 | joncdavid/touretzky-lisp-exercises | 3 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:27:44 AM (Europe/Amsterdam) | 2e6c8104a31413bcc6ffe70c4dfe2bf03592d889e85ec895e82e7b13fe3321fb | 17,138 | [
-1
] |
17,139 | ex-04-13.lisp | joncdavid_touretzky-lisp-exercises/chp4-conditionals/ex-04-13.lisp | ; file: ex-04-13.lisp
; author: Jon David
; date: Saturday, July 12, 2014
; description:
; exercise 4.13 - Write a function HOWCOMPUTE that is the inverse
; of the COMPUTE function described previously. HOWCOMPUTE takes
; three numbers as input and figures out what operation would produce
; the third from the ... | 910 | Common Lisp | .lisp | 23 | 38 | 71 | 0.695357 | joncdavid/touretzky-lisp-exercises | 3 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:27:44 AM (Europe/Amsterdam) | 12bb7d6e8347b4befaa51cde0cd371120bb41e106036ea9f0db5aeb1503fcd1f | 17,139 | [
-1
] |
17,140 | ex-04-02.lisp | joncdavid_touretzky-lisp-exercises/chp4-conditionals/ex-04-02.lisp | ; file: ex-04-02.lisp
; author: Jon David
; date: Saturday, July 12, 2014
; description:
; exercise 4.2 - Write a function FURTHER that makes a positive
; number larger by adding one to it, and a negative number smaller
; by subtracting one from it. What does your function do if given
; the number 0?
(defun f... | 386 | Common Lisp | .lisp | 12 | 30.666667 | 68 | 0.672043 | joncdavid/touretzky-lisp-exercises | 3 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:27:44 AM (Europe/Amsterdam) | 3bd613344dd5bf91e3b05c5225e12565e376ab0935498acfd02f763a7d104427 | 17,140 | [
-1
] |
17,141 | ex-04-18.lisp | joncdavid_touretzky-lisp-exercises/chp4-conditionals/ex-04-18.lisp | ; file: ex-04-18.lisp
; author: Jon David
; date: Saturday, July 12, 2014
; description:
; exercise 4.18 - Write a function to act as referee in the
; ROCK-SCISSORS-PAPER game.
(defun rockp (hand)
(equal hand 'ROCK))
(defun scissorp (hand)
(equal hand 'SCISSOR))
(defun paperp (hand)
(equal hand 'PAPER))
... | 527 | Common Lisp | .lisp | 18 | 27.277778 | 61 | 0.676587 | joncdavid/touretzky-lisp-exercises | 3 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:27:44 AM (Europe/Amsterdam) | 263e81d25d2376e68c6282557c5fc3f2a1f6fce856b83703699170c8d0f31ca8 | 17,141 | [
-1
] |
17,142 | ex-04-36.lisp | joncdavid_touretzky-lisp-exercises/chp4-conditionals/ex-04-36.lisp | ; file: ex-04-36.lisp
; author: Jon David
; date: Saturday, July 12, 2014
; description:
; exercise 4.36 - The NAND function (NAND is short for Not AND) is
; very commonly found in computer circuitry. Here is a definition
; of NAND. Write down its truth table.
;
; SOLUTION:
;
; NAND truth table:
; | x | y |... | 590 | Common Lisp | .lisp | 20 | 28.4 | 68 | 0.484211 | joncdavid/touretzky-lisp-exercises | 3 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:27:44 AM (Europe/Amsterdam) | 4b1fd7f174688c105eb0127aa41f3e01dd5636e75116fcebd340e890aa5653d1 | 17,142 | [
-1
] |
17,143 | ex-04-19.lisp | joncdavid_touretzky-lisp-exercises/chp4-conditionals/ex-04-19.lisp | ; file: ex-04-19.lisp
; author: Jon David
; date: Saturday, July 12, 2014
; description:
; exercise 4.19 - Show how to write the expression (AND X Y Z W)
; using COND instead of AND. Then show how to write it using IFs
; instead of AND.
(defun and-cond (x y z w)
(cond ((null x) nil)
((null y) nil)
((null z)... | 479 | Common Lisp | .lisp | 21 | 19.809524 | 67 | 0.592105 | joncdavid/touretzky-lisp-exercises | 3 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:27:44 AM (Europe/Amsterdam) | 36f65648f955cb5f6fb11ee361114df450839a2b38ee494ec870266ee7dd9d2b | 17,143 | [
-1
] |
17,144 | ex-04-30.lisp | joncdavid_touretzky-lisp-exercises/chp4-conditionals/ex-04-30.lisp | ; file: ex-04-30.lisp
; author: Jon David
; date: Saturday, July 12, 2014
; description:
; exercise 4.30 - Write LOGICAL-OR. Make sure it only returns T
; or NIL for its result.
(defun logical-or (x y)
(or (not (null x)) (not (null y))))
| 248 | Common Lisp | .lisp | 8 | 29.375 | 66 | 0.670886 | joncdavid/touretzky-lisp-exercises | 3 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:27:44 AM (Europe/Amsterdam) | 784c5b923f60ea04e186dd6776189febcb59a0ce1ce36963416b4c850cd0e6e5 | 17,144 | [
-1
] |
17,145 | ex-04-15.lisp | joncdavid_touretzky-lisp-exercises/chp4-conditionals/ex-04-15.lisp | ; file: ex-04-15.lisp
; author: Jon David
; date: Saturday, July 12, 2014
; description:
; exercise 4.15 - Write a predicate called GEQ that returns T if
; its first input is greater than or equal to its second input.
(defun geq (x y)
(or (> x y) (equal x y)))
| 272 | Common Lisp | .lisp | 8 | 32.125 | 66 | 0.694981 | joncdavid/touretzky-lisp-exercises | 3 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:27:44 AM (Europe/Amsterdam) | 530bda2f36e46cd4591ef32bfabe928f311b6de38c371c661aff1d27d16060c4 | 17,145 | [
-1
] |
17,146 | ex-04-08.lisp | joncdavid_touretzky-lisp-exercises/chp4-conditionals/ex-04-08.lisp | ; file: ex-04-08.lisp
; author: Jon David
; date: Saturday, July 12, 2014
; description:
; exercise 4.8 - Write EMPHASIZE3, which is like EMPHASIZE2 but adds
; the symbol VERY onto the list if it doesn't know how to emphasize
; it. For example, EMPHASIZE3 of (LONG DAY) shold produce
; (VERY LONG DAY). What do... | 441 | Common Lisp | .lisp | 11 | 38.727273 | 70 | 0.703963 | joncdavid/touretzky-lisp-exercises | 3 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:27:44 AM (Europe/Amsterdam) | eed9d156715d2bab5f443714100e6436da4104ff5b35148bb044956c1328224d | 17,146 | [
-1
] |
17,147 | ex-04-11.lisp | joncdavid_touretzky-lisp-exercises/chp4-conditionals/ex-04-11.lisp | ; file: ex-04-11.lisp
; author: Jon David
; date: Saturday, July 12, 2014
; description:
; exercise 4.11 - Write a function FIRSTZERO that takes a list of
; three numbers as input and returns a word (one of "first",
; "second", "third", or "none") indicating where the first zero
; appears in the list. Example:... | 651 | Common Lisp | .lisp | 16 | 39.25 | 69 | 0.696682 | joncdavid/touretzky-lisp-exercises | 3 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:27:44 AM (Europe/Amsterdam) | 93c37509cc29ba2116c37bab9d57ed122174a03b492d35408a49600494880517 | 17,147 | [
-1
] |
17,148 | ex-04-21.lisp | joncdavid_touretzky-lisp-exercises/chp4-conditionals/ex-04-21.lisp | ; file: ex-04-21.lisp
; author: Jon David
; date: Saturday, July 12, 2014
; description:
; exercise 4.21 - Write a version of the GTEST function using
; IF and COND.
;
; NOTE:
; gtest returns true if the x > y or if either one is not 0.
(defun gtest-cond (x y)
(cond ((> x y) t)
((equal x 0) t)
((equal y 0) ... | 427 | Common Lisp | .lisp | 18 | 21.5 | 63 | 0.60688 | joncdavid/touretzky-lisp-exercises | 3 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:27:44 AM (Europe/Amsterdam) | 5bb5ad977da5c6ca30e164b56d09f39d9195bf3a838a390df60fc5c4dcc11cbe | 17,148 | [
-1
] |
17,298 | packages.lisp | jnjcc_cl-ml/packages.lisp | ;;;; Copyright (c) 2012-2015 jnjcc, Yste.org. All rights reserved.
;;;;
;;;; Machine Learning in Common Lisp
(in-package #:cl-user)
(defpackage #:cl-ml
(:nicknames #:ml)
(:use #:cl #:cl-ml/probs #:cl-ml/linalg #:cl-ml/algo)
(:export #:precision-score #:recall-score #:f1-score #:accuracy-score
#:confu... | 1,360 | Common Lisp | .lisp | 33 | 31.454545 | 71 | 0.595906 | jnjcc/cl-ml | 3 | 0 | 0 | GPL-2.0 | 9/19/2024, 11:27:44 AM (Europe/Amsterdam) | 727b981e30112232e9b2478ca1f683fb0bc737855578fd793cd74dab39c5052a | 17,298 | [
-1
] |
17,299 | kmeans-test.lisp | jnjcc_cl-ml/test/kmeans-test.lisp | ;;;; Copyright (c) 2012-2015 jnjcc, Yste.org. All rights reserved.
;;;;
;;;; Unsupervised Learning > clustering > k-Means clustering
(in-package #:cl-ml/test)
(define-test unsupervised-kmeans-test
(let ((X (copy-matrix *iris-train*))
(kmeans (make-instance 'kmeans-cluster :epochs 300 :ninit 1
... | 1,061 | Common Lisp | .lisp | 22 | 40.363636 | 85 | 0.597878 | jnjcc/cl-ml | 3 | 0 | 0 | GPL-2.0 | 9/19/2024, 11:27:44 AM (Europe/Amsterdam) | 8fe85234f3f69dac0a22e881337a84355ec45671af92cd954eb06d0a032a2956 | 17,299 | [
-1
] |
17,300 | linear-test.lisp | jnjcc_cl-ml/test/linear-test.lisp | ;;;; Copyright (c) 2012-2015 jnjcc, Yste.org. All rights reserved.
;;;;
(in-package #:cl-ml/test)
(defvar *train* (make-square-matrix 3 :initial-contents
'((2 3 1)
(0 1 3)
(1 2 5))))
(defvar *weight* (make-... | 2,931 | Common Lisp | .lisp | 60 | 41.683333 | 100 | 0.60985 | jnjcc/cl-ml | 3 | 0 | 0 | GPL-2.0 | 9/19/2024, 11:27:44 AM (Europe/Amsterdam) | 57b63b4618ac0a16c2165cb3f87f85607e0378eaf692cf67cc86b69ec2bebf5a | 17,300 | [
-1
] |
17,301 | linalg-test.lisp | jnjcc_cl-ml/test/linalg-test.lisp | ;;;; Copyright (c) 2012-2015 jnjcc, Yste.org. All rights reserved.
;;;;
(in-package #:cl-ml/test)
(defvar *matrix* (make-matrix 3 5 :initial-contents
'((1 2 3 1 5)
(6 0 1 3 0)
(7 1 2 5 1))))
(defvar *square* (make-square-mat... | 6,920 | Common Lisp | .lisp | 158 | 31.158228 | 95 | 0.484813 | jnjcc/cl-ml | 3 | 0 | 0 | GPL-2.0 | 9/19/2024, 11:27:44 AM (Europe/Amsterdam) | 6b49f571a5168ff749128a05b03bec7b825d96e67fe85682e22fef8fef44f570 | 17,301 | [
-1
] |
17,302 | algo-test.lisp | jnjcc_cl-ml/test/algo-test.lisp | ;;;; Copyright (c) 2012-2015 jnjcc, Yste.org. All rights reserved.
;;;;
(in-package #:cl-ml/test)
(define-test split-string-test
(let* ((str "ab,cd,ab,ef,gh,abab")
(bychr (split-string str #\,))
(bystr (split-string str "ab"))
(byspc (split-string str #\Space)))
;; '("ab" "cd" "ab" "e... | 2,819 | Common Lisp | .lisp | 81 | 28.123457 | 83 | 0.55185 | jnjcc/cl-ml | 3 | 0 | 0 | GPL-2.0 | 9/19/2024, 11:27:44 AM (Europe/Amsterdam) | fa1d77b0a36ef7977dd33b613821cba80838425a1fba7edfbfce19a0a62f856c | 17,302 | [
-1
] |
17,303 | forest-test.lisp | jnjcc_cl-ml/test/forest-test.lisp | ;;;; Copyright (c) 2012-2015 jnjcc, Yste.org. All rights reserved.
;;;;
;;;; Random Forest test
(in-package #:cl-ml/test)
(define-test random-forest-classifier
(let ((y (copy-matrix *iris-label*))
;; 0: petal length, 1: petal width
(X (copy-matrix (make-matrix-view *iris-train* :col-view '(2 3))))
... | 1,069 | Common Lisp | .lisp | 24 | 38.375 | 93 | 0.616715 | jnjcc/cl-ml | 3 | 0 | 0 | GPL-2.0 | 9/19/2024, 11:27:44 AM (Europe/Amsterdam) | 2cbeaded8a371bf077712d17c3a5291264d12ca10404259a253da0bf14aa430a | 17,303 | [
-1
] |
17,304 | tests.lisp | jnjcc_cl-ml/test/tests.lisp | ;;;; Copyright (c) 2012-2015 jnjcc, Yste.org. All rights reserved.
;;;;
(in-package #:cl-ml/test)
(defun run-all-tests ()
(let ((result (run-tests :all :cl-ml/test)))
(test-names result)
result))
| 208 | Common Lisp | .lisp | 7 | 27 | 66 | 0.648241 | jnjcc/cl-ml | 3 | 0 | 0 | GPL-2.0 | 9/19/2024, 11:27:44 AM (Europe/Amsterdam) | 209be3096078cda410f9b82cac2a25b424ef737e1700942de052f7f5121e3934 | 17,304 | [
-1
] |
17,305 | graph-test.lisp | jnjcc_cl-ml/test/graph-test.lisp | ;;;; Copyright (c) 2012-2015 jnjcc, Yste.org. All rights reserved.
;;;;
(in-package #:cl-ml/test)
(define-test undirected-graph-test
(let ((copy (copy-graph *karate-graph*)))
(assert-eq 34 (node-count *karate-graph*))
(assert-eq 76 (edge-count *karate-graph*))
(assert-true (has-node *karate-graph* 1))
... | 927 | Common Lisp | .lisp | 23 | 35.913043 | 66 | 0.651111 | jnjcc/cl-ml | 3 | 0 | 0 | GPL-2.0 | 9/19/2024, 11:27:44 AM (Europe/Amsterdam) | 96604d12b691ad532d774d935d6b36b8aec7ed922413da688456fbdadaedb8ce | 17,305 | [
-1
] |
17,306 | neural-test.lisp | jnjcc_cl-ml/test/neural-test.lisp | ;;;; Copyright (c) 2012-2015 jnjcc, Yste.org. All rights reserved.
;;;;
(in-package #:cl-ml/test)
(defun mlp-classifier-test (epochs lrate)
(let ((mlpclf (make-instance 'mlp-classifier :hidden-units '(2) :epochs epochs :learn-rate lrate))
(X (copy-matrix *iris-train*))
(y (load-iris-label-binary 0))... | 457 | Common Lisp | .lisp | 11 | 36.909091 | 100 | 0.641892 | jnjcc/cl-ml | 3 | 0 | 0 | GPL-2.0 | 9/19/2024, 11:27:44 AM (Europe/Amsterdam) | aa759de676a0080c1ef443f3697d97001bc2acb10641c8311aac0c5392040638 | 17,306 | [
-1
] |
17,307 | gbtree-test.lisp | jnjcc_cl-ml/test/gbtree-test.lisp | ;;;; Copyright (c) 2012-2015 jnjcc, Yste.org. All rights reserved.
;;;;
;;;; Gradient Boosting Tree test
(in-package #:cl-ml/test)
(define-test gradient-boost-regressor
(let* ((sz 1000)
(X (copy-matrix (mhead *cal-train* sz)))
(y (copy-matrix (mhead *cal-label* sz)))
(gbleast (make-instan... | 1,163 | Common Lisp | .lisp | 25 | 41.04 | 80 | 0.640529 | jnjcc/cl-ml | 3 | 0 | 0 | GPL-2.0 | 9/19/2024, 11:27:44 AM (Europe/Amsterdam) | 96fc3c5353e3258767faa157340a76bb6f07f5a6a96e96b5959c56ccb1da45aa | 17,307 | [
-1
] |
17,308 | prepro-test.lisp | jnjcc_cl-ml/test/prepro-test.lisp | ;;;; Copyright (c) 2012-2015 jnjcc, Yste.org. All rights reserved.
;;;;
(in-package #:cl-ml/test)
;; Polynomial Features
(defvar *poly-feature* (make-matrix 2 2 :initial-contents '((1 2) (3 4))))
;; Standard scaler
(define-test stand-scaler-iris
(let ((train (make-matrix 3 3 :initial-contents '((1 2 3) (2 3 1) (3 ... | 1,861 | Common Lisp | .lisp | 35 | 45.628571 | 91 | 0.617792 | jnjcc/cl-ml | 3 | 0 | 0 | GPL-2.0 | 9/19/2024, 11:27:44 AM (Europe/Amsterdam) | aa3cfc1d22d627f7822f29e611ab653b98272b3673b5f4931dd7542b041e347d | 17,308 | [
-1
] |
17,309 | xgboost-test.lisp | jnjcc_cl-ml/test/xgboost-test.lisp | ;;;; Copyright (c) 2012-2015 jnjcc, Yste.org. All rights reserved.
;;;;
;;;; XGBoost test
(in-package #:cl-ml/test)
(define-test xgboost-regressor-test
(let* ((sz 1000)
(X (copy-matrix (mhead *cal-train* sz)))
(y (copy-matrix (mhead *cal-label* sz)))
(xgreg (make-instance 'xgboost-regress... | 429 | Common Lisp | .lisp | 11 | 34.454545 | 69 | 0.627404 | jnjcc/cl-ml | 3 | 0 | 0 | GPL-2.0 | 9/19/2024, 11:27:44 AM (Europe/Amsterdam) | a438b3dd3c85e1bd8a6c7d783430c42d1e06a371f15abc599ab904beb84017e0 | 17,309 | [
-1
] |
17,310 | common.lisp | jnjcc_cl-ml/test/common.lisp | ;;;; Copyright (c) 2012-2015 jnjcc, Yste.org. All rights reserved.
;;;;
(in-package #:cl-ml/test)
(defvar *test-stream* nil)
;;; utility functions
(defun matrix-eq (ma mb &optional (eq #'=))
(when (and (= (nrow ma) (nrow mb)) (= (ncol ma) (ncol mb)))
(do-matrix (i j ma)
(unless (funcall eq (mref ma i j) ... | 768 | Common Lisp | .lisp | 24 | 28.791667 | 66 | 0.63365 | jnjcc/cl-ml | 3 | 0 | 0 | GPL-2.0 | 9/19/2024, 11:27:44 AM (Europe/Amsterdam) | d0cf4b578e1a26f150a2e3a11af3c0addf1f6ad7e7b9ce7b507782705685b034 | 17,310 | [
-1
] |
17,311 | dtree-test.lisp | jnjcc_cl-ml/test/dtree-test.lisp | ;;;; Copyright (c) 2012-2015 jnjcc, Yste.org. All rights reserved.
;;;;
;;;; Decision Tree test
(in-package #:cl-ml/test)
(define-test decision-tree-classifier
"Binary tree of the form:
[length <= 2.45]
/ \
Iris-setosa [width <= 1.75]
/ \
... | 2,505 | Common Lisp | .lisp | 50 | 38.3 | 85 | 0.54097 | jnjcc/cl-ml | 3 | 0 | 0 | GPL-2.0 | 9/19/2024, 11:27:44 AM (Europe/Amsterdam) | 6ee0c1a0f7ad11ae54086899007b8cd8631c57ed0474c815f524aa536e57b9b9 | 17,311 | [
-1
] |
17,312 | metrics-test.lisp | jnjcc_cl-ml/test/metrics-test.lisp | ;;;; Copyright (c) 2012-2015 jnjcc, Yste.org. All rights reserved.
;;;;
(in-package #:cl-ml/test)
(define-test clf-metrics-test
(let ((ylabl (make-vector 10 :initial-contents '(1 0 0 0 1 0 1 0 0 0)))
(ypred (make-vector 10 :initial-contents '(1 1 0 0 1 1 1 0 0 0))))
(assert-eq 0.6 (precision-score ylabl... | 1,634 | Common Lisp | .lisp | 31 | 47.064516 | 80 | 0.623515 | jnjcc/cl-ml | 3 | 0 | 0 | GPL-2.0 | 9/19/2024, 11:27:44 AM (Europe/Amsterdam) | 4242ad9e97eaa52223ec46ce1909d57f69de8794885d3585ead086886fd48ce1 | 17,312 | [
-1
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.