Questions tagged [on-lisp]

Paul Graham's On Lisp (1993) covers a number advanced Lisp programming techniques. Use this tag for questions about code or techniques presented in this book.

Paul Graham's On Lisp (1993) covers advanced Lisp programming techniques. It is available online in HTML and PDF from the author's website.

14 questions
14
votes
3 answers

Strange Lisp Quoting scenario - Graham's On Lisp, page 37

I'm working my way through Graham's book "On Lisp" and can't understand the following example at page 37: If we define exclaim so that its return value incorporates a quoted list, (defun exclaim (expression) (append expression ’(oh my))) > …
Nick Alger
  • 984
  • 7
  • 26
13
votes
1 answer

Bizarre quoted list example from On Lisp

This passage from On Lisp is genuinely confusing -- it is not clear how returning a quoted list such as '(oh my) can actually alter how the function behaves in the future: won't the returned list be generated again in the function from scratch, the…
johnbakers
  • 24,158
  • 24
  • 130
  • 258
5
votes
1 answer

continuation in common lisp by macros -- regarding an implemetation in OnLisp

In On Lisp, p. 267, Paul Graham provides an implementation of continuation passing macros: (setq *cont* #'identity) (defmacro =lambda (parms &body body) `#'(lambda (*cont* ,@parms) ,@body)) (defmacro =defun (name parms &body body) (let ((f…
4
votes
2 answers

Learn Macros in Scheme from On Lisp

I really want to learn Scheme macros. I glanced over the content of "On Lisp" and a lot of the chapters have been devoted to Lisp macros. However I do not know common lisp. Can I use it to learn Scheme Macros?
unj2
  • 52,135
  • 87
  • 247
  • 375
3
votes
1 answer

"On Lisp": `(a b c) vs '(a b c) vs (list 'a 'b 'c)

In On Lisp (p. 84) Graham says ‘(a b c) (without comma) is equal to ’(a b c) and then says A backquoted list is equivalent to a call to list with the elements quoted.That is, ‘(a b c) (without comma) is equal to (list ’a ’b ’c). One…
Frank
  • 433
  • 3
  • 10
3
votes
1 answer

about the Prolog implementation

I just want to add the capability to handle lisp query into the initial Prolog implementation in OnLisp text. Since this capability is introduced in the following chapater (a new implementation), I just copied from new implementation and made some…
user1461328
  • 742
  • 2
  • 6
  • 13
3
votes
1 answer

Is this really a breadth first search

There is a piece of pseudo code of a breadth first search on P.303 of OnLisp which is show below. For the graph below, it will first process node 1, and then put node 2, 3 and 4 into the queue and then just iteratively call itself again. Then, it…
user1461328
  • 742
  • 2
  • 6
  • 13
3
votes
1 answer

The necessity of quote in On Lisp's #[ read macro?

I am reading On Lisp and cannot make out why the code below has use a quote. Here is the excerpt from the text: Another character combination reserved for the user is #[. Figure 17.3 gives an example of how this character might be defined as a…
user1461328
  • 742
  • 2
  • 6
  • 13
1
vote
3 answers

Are (let) and (lambda) equivalent in Common Lisp

I'm reading On Lisp by Paul Graham, trying to better understand the functional style of programming. In Chapter 3, he mentions that functional programs "work by returning values" rather than performing side effects. I don't quite understand the…
myselfesteem
  • 733
  • 1
  • 6
  • 23
1
vote
1 answer

Tail-recursive flatten function in Emacs Lisp

I'm going through Paul Graham's On Lisp, and trying to implement the functions in Emacs Lisp. One of them is flatten : (flatten '(a (b c) ((d e) f))) ;; Returns: (a b c d e f) Yet for some reason, the implementation given by Paul Graham does not…
kotchwane
  • 2,082
  • 1
  • 19
  • 24
1
vote
4 answers

Flatten a list using common lisp

I was reading the book On Lisp by Paul Graham. In Chapter 4, Utility Functions, he gives examples of small functions that operate on lists, which would be helpful while writing a larger program. One of them is flatten. Given a nested list at any…
ardsrk
  • 2,407
  • 2
  • 21
  • 33
1
vote
1 answer

Is this a good correction for "our-find-if" at Graham's OnLisp page 23 errata?

Paul Graham's 'On Lisp' errata page states: p. 23. our-find-if would recurse infinitely if no element matches. Caught by Markus Triska. The function definition as shown in the book is: (defun our-find-if (fn lst) (if (funcall fn (car lst)) …
AndRAM
  • 155
  • 1
  • 10
0
votes
3 answers

Difference between (apply #'somefunc args) and (somefunc args)

While reading Paul Graham's On Lisp I found the following function in Chapter 4, Utility Functions. (defun symb (&rest args) (values (intern (apply #'mkstr args)))) ;; mkstr function is "applied" ;; which evaluates like in the following example: >…
licorna
  • 5,670
  • 6
  • 28
  • 39
0
votes
1 answer

regarding continuation in OnLisp

I am still interested in the question which has been answered. continuation in common lisp by macros — regarding an implemetation in OnLisp What will happen if Paul Graham's assumption is correct especially when change from (A 5) to (B 1)? What is…
user1461328
  • 742
  • 2
  • 6
  • 13