[clean-list] list: atom?

Maks Verver m.verver@student.utwente.nl
Mon, 25 Nov 2002 18:46:56 +0100


Hi Luis,

The Scheme pair is somewhat special, in that it is used both for
2-tuples and lists. When used as a list, they are constructed the same
way as in Clean: each first element contains an element of this list and
the second element contains the rest of the list (which could be the
empty list). However, finite lists must end with the empty list as
second element.

So, the Scheme list (1 2 3) would be notated in Clean as [1,2,3]. These
lists are equal to (1.(2.(3.()))) in Scheme and [1:[2:[3:[]]]] in Clean
respectively. The Scheme pair (1.2) would be represented as a 2-tuple
(1,2) in Clean, which is a different type.

Because of this distinction, the 'pair?' and 'atom?' functions aren't
useful in Clean. In any case, if you did want to implement them, you
would do so easily with pattern matching.

If you wish, you can ofcourse use 2-tuples to create list structures in
Clean. However, this means you cannot take advantage of the existing
functiones operating on 'real' lists. You may think of Clean lists as
being algebraic datatypes that use 2-tuples already, something along the
lines of:

::List type = (type, List type) | EmptyList

But because of the special syntax, you can not use lists as if they were
tuples (for example, you can't pass a list to a function that accepts
any kind of 2-tuple). I must admit I am not sure why lists are so
special. Ofcourse, the syntactic sugar that allows easy construction and
matching of lists is useful (just as in Scheme) but I don't know why
functions accepting 2-tuples can't accept lists (or the other way
around). Does anyone have an idea about this?


Kind regards,
Maks Verver.


> -----Original Message-----
> From: clean-list-admin@cs.kun.nl 
> [mailto:clean-list-admin@cs.kun.nl] On Behalf Of luis burgos
> Sent: donderdag 21 november 2002 7:30
> To: clean-list@cs.kun.nl
> Subject: [clean-list] list: atom?
> 
> 
> hello, I am new to this list, and also to Clean.....a 
> question here: are 
> there any functions like atom? or pair?  (like Scheme) to apply on a 
> element of a list??
> 
> will appreciate your help,
> 
> luis burgos
>