Tom Pledger <[EMAIL PROTECTED]>  writes

> [..]
> lazinessTest  = head $ fst $ partition  (==1) [0..]
> lazinessTest' = head $ fst $ partition' (==1) [0..]
>
> Main> lazinessTest
>
>  (35927 reductions, 63879 cells)
>  ERROR: Control stack overflow
>  Main> lazinessTest'
>  1
>  (36 reductions, 73 cells)
> 
> Any ideas about why this happens, please?


By the way, the  List.partition  definition
                         \p xs -> (filter p xs, filter (not .p) xs)

is not it the simplest and the best implementation?
It looks like the existing implementations do not use it.

Correctness question
--------------------
The implementations optimize the standard functions in various ways.
But what about correctness, what the standard says?
For example, the definition from the  List.partition  _document_
implies that
             head $ fst $ partition (==1) [0..]    = 1

And some implementations get into infinite loop at this
(may this loop be called `undefined', is it equivalent ?).

What freedom the language and library description allows with this
respect?

------------------
Sergey Mechveliani
[EMAIL PROTECTED]






Reply via email to