Wave 4: add sequences/vectors/files chapters, 23 exercises, quiz3, finish ceremony, PCL table
This commit is contained in:
1 parent
77843402fa
commit
4675bd1106
76 files changed
+2505
-14
No files matched your search
@@ -0,0 +1,27 @@
|
||||
;;; SEQUENCES 4: EVERY, SOME, SEARCH, MERGE (solution)
|
||||
|
||||
(defun all-fit (f xs)
|
||||
(every f xs))
|
||||
|
||||
(defun needle-at (needle hay)
|
||||
(search needle hay))
|
||||
|
||||
(defun weave (a b)
|
||||
(merge 'list a b #'<))
|
||||
|
||||
;;; ------------------------------------------------------------------
|
||||
;;; Checks. Read them - they tell you what to aim for - but leave
|
||||
;;; them unchanged.
|
||||
;;; ------------------------------------------------------------------
|
||||
|
||||
(check-equal t (all-fit #'plusp '(1 2 3)))
|
||||
(check-equal nil (all-fit #'plusp '(-1 2 3)))
|
||||
(check-equal t (all-fit #'plusp '()))
|
||||
(check (some #'minusp '(1 -2 3)))
|
||||
(check-equal 1 (needle-at '(b c) '(a b c d)))
|
||||
(check-equal 2 (needle-at '(2 3) '(1 5 2 3)))
|
||||
(check-equal 1 (needle-at "ana" "banana"))
|
||||
(check-equal nil (needle-at '(9) '(1 2 3)))
|
||||
(check-equal '(1 2 3 4) (weave (list 1 3) (list 2 4)))
|
||||
(check-equal '(0 1 4 9) (weave (list 4) (list 0 1 9)))
|
||||
(check-equal '(2 3) (weave (list 2 3) (list)))
|
||||
Reference in new issue
Block a user