[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-users] list of more than 2 elements is pair?

From: Paul Sika
Subject: Re: [Chicken-users] list of more than 2 elements is pair?
Date: Mon, 10 Dec 2018 12:13:21 +0000

hi Thomas, 
thank you very much. it is indeed clear from your explanation. it is about the cons cells.

But i must say that at the back of the mind it feels like it should not satisfy pair? because there are 3 elements in the list.

That said, I shall keep learning :-) 

thanks again, Thomas.

On Mon, Dec 10, 2018 at 12:00 PM Thomas Chust <address@hidden> wrote:
On Mon, 10 Dec 2018 11:48:56 +0000 Paul Sika <address@hidden> wrote:

> [...]
> I am trying a scheme tutorial using the chicken repl and i see that
> (pair? '(1 2 3))  yields true.
> is this normal ?
> [...]

Hello Paul,

yes, this is perfectly normal: Every non-empty list satisfies the pair?
predicate because lists are linked chains of cons cells.

The _expression_

  '(1 2 3)

can also be represented by the the following more verbose notation,
which matches its in-memory structure more closely:

  '(1 . (2 . (3 . ())))

Everything represented by '(X . Y) or produced by (cons X Y) will
satisfy pair?.

I hope this helps :-)


When C++ is your hammer, every problem looks like your thumb.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]