From 5b3b5eaa2f8c958f7e11fb7d98177433027af13b Mon Sep 17 00:00:00 2001 From: Sasank Chilamkurthy Date: Thu, 12 Oct 2023 14:33:34 +0530 Subject: [PATCH 1/6] Fix typos in chapter9.md --- docs/chapter9.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/chapter9.md b/docs/chapter9.md index 268e07e..1ada0cb 100644 --- a/docs/chapter9.md +++ b/docs/chapter9.md @@ -422,8 +422,8 @@ Finally, if there are several elements in the right-hand side, they are each tur (let ((rhs (rule-rhs rule))) '(defun ,(rule-lhs rule) () ,(cond ((every #'atom rhs) '(one-of ',rhs)) - ((length =l rhs) (build-code (first rhs))) - (t '(case (random .(length rhs)) + ((length=l rhs) (build-code (first rhs))) + (t '(case (random ,(length rhs)) ,@(build-cases 0 rhs))))))) (defun build-cases (number choices) From 42e92350e97a373ca108150b6c902b03580693ac Mon Sep 17 00:00:00 2001 From: Sasank Chilamkurthy Date: Thu, 12 Oct 2023 15:02:52 +0530 Subject: [PATCH 2/6] Further typos --- docs/chapter9.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/chapter9.md b/docs/chapter9.md index 1ada0cb..9fc8a36 100644 --- a/docs/chapter9.md +++ b/docs/chapter9.md @@ -420,10 +420,10 @@ Finally, if there are several elements in the right-hand side, they are each tur (defun compile-rule (rule) "Translate a grammar rule into a LISP function definition." (let ((rhs (rule-rhs rule))) - '(defun ,(rule-lhs rule) () + `(defun ,(rule-lhs rule) () ,(cond ((every #'atom rhs) '(one-of ',rhs)) ((length=l rhs) (build-code (first rhs))) - (t '(case (random ,(length rhs)) + (t `(case (random ,(length rhs)) ,@(build-cases 0 rhs))))))) (defun build-cases (number choices) From c71aeb15d8e10f303b223bec41b17f3242d987c4 Mon Sep 17 00:00:00 2001 From: Sasank Chilamkurthy Date: Mon, 16 Oct 2023 11:44:31 +0530 Subject: [PATCH 3/6] Fix struct in section 9.3 --- docs/chapter9.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/chapter9.md b/docs/chapter9.md index 9fc8a36..ebd0111 100644 --- a/docs/chapter9.md +++ b/docs/chapter9.md @@ -621,11 +621,11 @@ The function `force` checks if the function needs to be called, and returns the If `force` is passed an argument that is not a delay, it just returns the argument. ```lisp -(defstruct delay value (computed? nil)) +(defstruct delay (value nil) (function nil)) (defmacro delay (&rest body) "A computation that can be executed later by FORCE." - `(make-delay :value #'(lambda () . ,body))) + `(make-delay :function #'(lambda () . ,body))) ``` ```lisp From 4fb7c73661a907dfeed707bc72b7c4ec99243b86 Mon Sep 17 00:00:00 2001 From: Sasank Chilamkurthy Date: Mon, 16 Oct 2023 11:52:55 +0530 Subject: [PATCH 4/6] Fix defmacro backquote --- docs/chapter9.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/chapter9.md b/docs/chapter9.md index ebd0111..4c1439b 100644 --- a/docs/chapter9.md +++ b/docs/chapter9.md @@ -676,7 +676,7 @@ Note that `make-pipe` is a macro that delays evaluation of the tail. ```lisp (defmacro make-pipe (head tail) "Create a pipe by evaluating head and delaying tail." - '(cons ,head (delay ,tail))) + `(cons ,head (delay ,tail))) (defconstant empty-pipe nil) (defun head (pipe) (first pipe)) (defun tail (pipe)(force (rest pipe))) From 6dbeb2376ff8c8af2c0641a3b1a1573331f8276f Mon Sep 17 00:00:00 2001 From: Sasank Chilamkurthy Date: Mon, 16 Oct 2023 12:23:55 +0530 Subject: [PATCH 5/6] Update chapter9.md --- docs/chapter9.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/chapter9.md b/docs/chapter9.md index 4c1439b..c563187 100644 --- a/docs/chapter9.md +++ b/docs/chapter9.md @@ -750,7 +750,7 @@ The following definitions do not make this assumption: ```lisp (defmacro make-pipe (head tai1) "Create a pipe by evaluating head and delaying tail." - '(cons ,head #'(lambda () ,tail))) + `(cons ,head #'(lambda () ,tail))) (defun tail (pipe) "Return tail of pipe or list, and destructively update the tail if it is a function." From ce9d35b8c6d3c6132b88a9fa78464a57c97c9ef2 Mon Sep 17 00:00:00 2001 From: Sasank Chilamkurthy Date: Mon, 16 Oct 2023 12:32:48 +0530 Subject: [PATCH 6/6] Update chapter9.md --- docs/chapter9.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/chapter9.md b/docs/chapter9.md index c563187..17fbff1 100644 --- a/docs/chapter9.md +++ b/docs/chapter9.md @@ -808,7 +808,7 @@ Here are some more utility functions on pipes: (progn (unless (null key) (funcall key (head pipe))) (enumerate (tail pipe) :count (if count (- count 1)) - : key key : result result)))) + :key key :result result)))) (defun filter (pred pipe) "Keep only items in pipe satisfying pred." (if (funcall pred (head pipe))