"Serge D. Mechveliani" <[EMAIL PROTECTED]> writes:
> The library functions like minimum, maximum, should perform in a
> constant space: probably, it is easy to write them his way.
I haven't given it much thought, but it seems that the rather obvious:
Prelude> minimum [1..10^6]
*** Exception: stack overflow
Prelude> :i minimum
-- minimum is a variable
minimum :: forall a. (Ord a) => [a] -> a
Prelude> let { mini m (x:xs) = if m <= x then mini m xs else mini x
xs; mini m [] = m}
Prelude> let minimum' (x:xs) = mini x xs
Prelude> minimum' [1..10^6]
1
does the trick (unlike the foldr version, which presumably is used by
the Prelude). No?
-kzm
--
If I haven't seen further, it is by standing in the footprints of giants
_______________________________________________
Glasgow-haskell-users mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users