0

I'm learning Lisp. I'm implementing solution to some relatively simple problem. I'm thinking of list that represents initial state of problem like this

((0 1) (2 3) (5 4))

I want to create variable and assign that list to it. I've tried

(let ((initial-state ((0 1) (2 3) (5 4)))))

but this won't compile. After that I've tried

(let ((initial-state list (list 0 1) (list 2 3) (list 5 4))))

this works, but it's too long. Is there better way to do this?

viktor
  • 1,277
  • 10
  • 16

2 Answers2

5
(let ((initial-state '((0 1) (2 3) (4 5))))
  ...)

The ' expands to (quote ...) which basically means "don't evaluate this, just return it to me as a list". It's used to separate data from code (which in lisp are related concepts).

mange
  • 3,172
  • 18
  • 27
3

Do you mean this?

(let ((initial-state '((0 1) (2 3) (5 4)))) ...)

That single quote is a quote. :) More about quoting here:

Community
  • 1
  • 1
Elias Dorneles
  • 22,556
  • 11
  • 85
  • 107