practical-common-lisp

once-only lisp macro, is my implementation correct?

ⅰ亾dé卋堺 提交于 2019-12-24 04:55:07
问题 I am trying to learn Lisp from Peter Seibel's book "Practical Common Lisp". In chapter 8 : "Macros: Defining your own", I came across this once-only macro. At the bottom of that page, an implementation is given. Now that is a pretty complicated macro to understand for me, so I saw this question on stackoverflow and there are some good explanations there. However, even if I (still) havent fully understood the macro, I understood its purpose. So I tried to write my own implementation of it :

Destructive sorting in lisp

别来无恙 提交于 2019-12-10 21:19:47
问题 I'm reading Practical Common Lisp . In chapter 11, it says this about sorting: Typically you won't care about the unsorted version of a sequence after you've sorted it, so it makes sense to allow SORT and STABLE-SORT to destroy the sequence in the course of sorting it. But it does mean you need to remember to write the following: (setf my-sequence (sort my-sequence #'string<)) I tried the following code: CL-USER> (defparameter *a* #( 8 4 3 9 5 9 2 3 9 2 9 4 3)) *A* CL-USER> *a* #(8 4 3 9 5 9

Common Lisp's copy-tree: Which objects will be referenced in common by the original and the copy?

為{幸葍}努か 提交于 2019-12-02 01:05:15
问题 I'm reading Practical Common Lisp, and have a question about Lisp's COPY-TREE function. The book gives the example of calling (copy-tree '( '(1 2) '(3 4) '(5 6))) After explaining it, the book makes this statement: Where a cons cell in the original referenced an atomic value, the corresponding cons cell in the copy will reference the same value. Thus, the only objects referenced in common by the original tree and the copy produced by COPY-TREE are the numbers 5, 6, and the symbol NIL. But

Common Lisp's copy-tree: Which objects will be referenced in common by the original and the copy?

旧时模样 提交于 2019-12-01 22:11:13
I'm reading Practical Common Lisp , and have a question about Lisp's COPY-TREE function. The book gives the example of calling (copy-tree '( '(1 2) '(3 4) '(5 6))) After explaining it, the book makes this statement: Where a cons cell in the original referenced an atomic value, the corresponding cons cell in the copy will reference the same value. Thus, the only objects referenced in common by the original tree and the copy produced by COPY-TREE are the numbers 5, 6, and the symbol NIL. But that doesn't make sense to me. I thought all atoms would be shared between the original and the new.

Understanding how to implement once-only lisp macro

荒凉一梦 提交于 2019-11-29 21:50:31
In Peter Seibel's book "Practical Common Lisp", we can find the definition of the very complicated macro once-only (see the bottom of page http://www.gigamonkeys.com/book/macros-defining-your-own.html ). I'm reading this macro definition for the 10th times in last 3 weeks and cannot understand how it works. :( Worse, I cannot develop this macro on my own, even though I understand its purpose and how to use it. I'm especially interested in systematic "derivation" of this notoriously hard macro, step by step! Any help? Are you looking at this: (defmacro once-only ((&rest names) &body body) (let

Understanding how to implement once-only lisp macro

人走茶凉 提交于 2019-11-28 17:43:10
问题 In Peter Seibel's book "Practical Common Lisp", we can find the definition of the very complicated macro once-only (see the bottom of page http://www.gigamonkeys.com/book/macros-defining-your-own.html). I'm reading this macro definition for the 10th times in last 3 weeks and cannot understand how it works. :( Worse, I cannot develop this macro on my own, even though I understand its purpose and how to use it. I'm especially interested in systematic "derivation" of this notoriously hard macro,