Questions tagged [land-of-lisp]

Land of Lisp is an educational comic that teaches readers how to program in Common Lisp.

30 questions
17
votes
2 answers

Can I save source files in Clisp?

I'm a beginner programmer and am going through the book "Land of Lisp". I have been typing in the examples from the book with the REPL. Is it possible to save my current program as a .lisp file so I can load it and continue working on it later? I…
MikeJerome
  • 640
  • 6
  • 18
13
votes
4 answers

Basic question about association list in Lisp

I'm reading "Land of Lisp" (which is by the way, one of the best technical books I have ever read) and I come across association list (defparameter *edges* '((living-room (garden west door) (attic upstairs ladder)) …
Chiron
  • 19,366
  • 15
  • 74
  • 132
10
votes
2 answers

Eliminating my explicit state passing via like, monads and stuff

I'm working through the book Land of Lisp in F# (yeah weird, I know). For their first example text adventure, they make use of global variable mutation and I'd like to avoid it. My monad-fu is weak, so right now I'm doing ugly state passing like…
J Cooper
  • 16,432
  • 11
  • 58
  • 104
10
votes
2 answers

Land of Lisp example redundency?

I've read a lot of good things about Land of Lisp so I thought that I might go through it to see what there was to see. (defun tweak-text (lst caps lit) (when lst (let ((item (car lst)) (rest (cdr lst))) (cond ; If item =…
cwallenpoole
  • 72,280
  • 22
  • 119
  • 159
10
votes
4 answers

Stack overflow from recursive function call in Lisp

I am learning Lisp from the book "The Land of Lisp" by Conrad Barski. Now I have hit my first stumbling block, where the author says: Calling yourself in this way is not only allowed in Lisp, but is often strongly encouraged after showing the…
mydoghasworms
  • 17,038
  • 9
  • 56
  • 88
9
votes
2 answers

Rewriting Wizard game of Land of Lisp in Clojure

I'm trying to rewrite the Wizard game from "Land of Lisp" http://landoflisp.com/wizards_game.lisp (def *nodes* {:living-room "you are in the living-room. a wizard is snoring loudly on the couch." :garden "you are in a beautiful garden.…
Chiron
  • 19,366
  • 15
  • 74
  • 132
9
votes
1 answer

Memoization with a closure example from Land of Lisp

On page 329 of Land of Lisp, Conrad Barski explains the technique of memoization with the following example code (let ((old-neighbors (symbol-function 'neighbors)) (previous (make-hash-table))) (defun neighbors (pos) (or (gethash pos…
Dominik Mokriš
  • 923
  • 1
  • 5
  • 22
8
votes
6 answers

Lisp parenthesis question

This piece of code is from book : "Land Of Lisp" First version is from book. When I read it, i thought there are parenthesis "(" not necessary just before "at-loc-p" at 2nd line and ")" just after loc at 3rd line. (defun person-at (loc pers…
Don Lun
  • 2,459
  • 6
  • 25
  • 32
6
votes
3 answers

Why can't CASE be used on string values and only symbol values?

In book 'land of lisp' I read Because the case command uses eq for comparisons, it is usually used only for branching on symbol values. It cannot be used to branch on string values, among other things. Please explain why?
skang404
  • 287
  • 1
  • 8
5
votes
3 answers

Using 'ash' in LISP to perform a binary search?

So, I'm reading Land of Lisp now, and Lisp is turning out to be quite different than other programming languages that I've seen. Anyways, the book provides some code that we're meant to enter into the CLISP REPL: (defparameter *small*…
Bhaxy
  • 4,866
  • 10
  • 34
  • 40
5
votes
3 answers

Evaluating macro arguments in clojure

I'm trying to translate the following macro from land of lisp into clojure: (defmacro tag (name atts &body body) `(progn (print-tag ',name (list ,@(mapcar (lambda (x) `(cons ',(car x)…
Adrian Mouat
  • 38,986
  • 15
  • 98
  • 99
4
votes
3 answers

Clisp REPL error output: how to find line number in file where error occurred?

I'm working through Land of Lisp, using CLisp, writing the code in Vim with Slimv, then alt-tabbing to another terminal window and loading the file into the REPL with (load 'file.lisp), then running the programs at the REPL. When I get an error in…
Kurtosis
  • 14,401
  • 7
  • 25
  • 38
3
votes
3 answers

How does the lambda function in lisp work?

I read in the book Land of Lisp that the lambda function is the only built-in function. However I don't really understand how that is possible because I thought you would at least need one command for addition, one for comparing numbers, and one for…
Noah
  • 315
  • 1
  • 8
3
votes
4 answers

Memory allocation in Lisp

> (cons 2 3) (2 . 3) The Lisp environment needs to allocate only a single cons cell to connect the two items. Above is from the Lisp book "Land of Lisp". I don't understand why this pair is only located in a single cons cell. What does the…
Josh Morrison
  • 6,958
  • 20
  • 63
  • 84
3
votes
2 answers

Code run in REPL but not if saved to a file

I'm trying to create a text based Clojure game (inspired by Land of Lisp). (def *nodes* {:living-room "you are in the living-room. a wizard is snoring loudly on the couch." :garden "you are in a beautiful garden. there is a well in…
Chiron
  • 19,366
  • 15
  • 74
  • 132
1
2