Skip to content

Commit e9e0089

Browse files
committed
Fix function dwim-map, add missing dependency, fix whitespace
* Fix function `dwim-map` in chapter 6. It left the first sequence out from the mapping. Add also new unit test for this function. It detects the issue and prevents regression. * Add missing dependency to the system definition. It made the system loading to fail on `ch14-compression.lisp` that uses flexi-streams. * Remove one unnecessary space from end of line.
1 parent 1a83448 commit e9e0089

File tree

3 files changed

+16
-7
lines changed

3 files changed

+16
-7
lines changed

ch6-lists.lisp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,12 @@
22

33
(defun dwim-map (fn seq &rest seqs)
44
"A thin wrapper over MAP that uses the type of the first SEQ for the result."
5-
(apply 'map (type-of seq) fn seqs))
5+
(apply 'map (type-of seq) fn (cons seq seqs)))
6+
7+
(deftest dwim-map ()
8+
(should be equal '(5 7 9)
9+
(dwim-map '+ '(1 2 3)
10+
'(4 5 6))))
611

712
(defun simple-mapcar-v1 (fn list)
813
(let ((rez (list)))
@@ -32,7 +37,7 @@
3237
(defun our-cons2 (data list)
3338
(when (null list) (setf list (make-our-own-list)))
3439
(let ((new-head (make-list-cell2
35-
:data data
40+
:data data
3641
:next (rtl:? list 'head))))
3742
(when (rtl:? list 'head)
3843
(setf (rtl:? list 'head 'prev) new-head))

errata.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
# Errata for *Programming Algorithms in Lisp*
22

3-
On **page xx** [Summary of error]:
4-
5-
Details of error here. Highlight key pieces in **bold**.
3+
On **page 79** Function `dwim-map` leaves the first sequence out. It should be:
4+
5+
```
6+
(defun dwim-map (fn seq &rest seqs)
7+
"A thin wrapper over MAP that uses the type of the first SEQ for the result."
8+
(apply 'map (type-of seq) fn (cons seq seqs)))
9+
```
610

711
***
812

progalgs.asd

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
(in-package #:asdf-user)
22

33
(defsystem #:progalgs
4-
:version "1.1"
4+
:version "1.2"
55
:description "Code for the book 'Programming Algorithms in Lisp'"
66
:author "Vsevolod Dyomkin <vseloved@gmail.com>"
77
:maintainer "Vsevolod Dyomkin <vseloved@gmail.com>"
8-
:depends-on (#:rutils #:eager-future2 #:sha1 #:lparallel #:should-test)
8+
:depends-on (#:rutils #:eager-future2 #:sha1 #:lparallel #:should-test #:flexi-streams)
99
:serial t
1010
:components ((:file "package")
1111
(:file "ch1-complexity")

0 commit comments

Comments
 (0)