chicken-users
[Top][All Lists]
Advanced

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

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


From: Thomas Chust
Subject: Re: [Chicken-users] list of more than 2 elements is pair?
Date: Mon, 10 Dec 2018 13:00:38 +0100

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 :-)

Ciao,
Thomas


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

Attachment: pgpfJDtLt0ulo.pgp
Description: PGP signature


reply via email to

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