1

Starting to learn scheme and I come across this:

What is the difference between

("v" . 1)

and

("v" 1)

They seem to work the same, just want to know what the difference. I tend to use ("v" 1), but ( cons "v" 1 ) returns ("v" . 1). So, what's the difference?

Thank you

graywolf
  • 7,092
  • 7
  • 53
  • 77

1 Answers1

5

("v" 1) is equal to (cons "v" (cons 1 '())) or ("v" . (1 . '())).

(foo . bar) is how a cons-cell is printed when it is not a proper list. A proper list is the constant '() (representing the empty list) or a cons-cell whose second element is a proper list. A proper list gets printed as (x1 x2 x3 etc) where the xi are the first elements of each cons-cell.

sepp2k
  • 363,768
  • 54
  • 674
  • 675