[clean-list] =?iso-8859-1?Q?Hidden_conventions??=

clean-list.mail.zooloo@xoxy.net clean-list.mail.zooloo@xoxy.net
Sun, 25 Jul 2004 23:58:01 +0200


I am quite new to FP, so my question concerns a rather basic issue.

In the CleanBook, chapter 3.3, there is something I don't
understand:

splitAt :: Int [a] -> ([a],[a])
splitAt 0 xs = ([],xs)
splitAt n [] = ([],[])
splitAt n [x:xs] = ([x:ys],zs)
where
    (ys,zs) = splitAt (n-1) xs.

Now I am wondering why that works. As far as I can see, there are two
contradicting definitions for the outcome of splitAt 0 [1..]:

1. ([],[1..])
2. ([1..],[]) (similarly to the example given at the beginning of
chapter 3.2.1.).


Which is the reason for the latter possibility being discarded?
I have some ideas about that, the most supposable ones of which are:

(a) perhaps because of the textual order
(b) because perhaps special cases (here: argument 0) overrule
overlapping general definitions (argument n)
(c) because perhaps finite structures (in 1. the first list becomes [])
take precedence over infinite ones (in 2. the first list becomes [1..])
(d) because there may be a convention that valid definitions overrule
competing invalid ones, and perhaps Clean can't compute the limit of
the second list series.

Is any of those true? If yes, are all other assumptions wrong?


Regards,
zooloo