Skip to main content
spelling fix
Source Link
Wilfred Hughes
  • 7k
  • 2
  • 33
  • 60

Q: how can I convert a 2-item list to a dotted pair cons cell?

I can convert a 2-item list to a dotted pair with:

(let ((list '(1 2)))
  (cons (car list) (cadr list)))        ; => (1 . 2)

I'm blanking: is there a built-in function that does this, or should I roleroll my own?

Q: how can I convert a 2-item list to a dotted pair cons cell?

I can convert a 2-item list to a dotted pair with:

(let ((list '(1 2)))
  (cons (car list) (cadr list)))        ; => (1 . 2)

I'm blanking: is there a built-in function that does this, or should I role my own?

Q: how can I convert a 2-item list to a dotted pair cons cell?

I can convert a 2-item list to a dotted pair with:

(let ((list '(1 2)))
  (cons (car list) (cadr list)))        ; => (1 . 2)

I'm blanking: is there a built-in function that does this, or should I roll my own?

edited tags
Link
Drew
  • 79.1k
  • 10
  • 123
  • 257
Source Link
Dan
  • 33.4k
  • 7
  • 106
  • 171

Convert 2-item list to a dotted pair?

Q: how can I convert a 2-item list to a dotted pair cons cell?

I can convert a 2-item list to a dotted pair with:

(let ((list '(1 2)))
  (cons (car list) (cadr list)))        ; => (1 . 2)

I'm blanking: is there a built-in function that does this, or should I role my own?