
On Wednesday 11 July 2007, Chaddaï Fouché wrote:
2007/7/11, Stefan O'Rear
: Interestingly, the function is already there; it's called genericLength.
However, the lazy natural type isn't.
I'm not sure what you mean there : genericLength is just a length that can return any Num (eg. an Integer) and not just Int, it has nothing to do with what Andrew wanted, which was a function that checked if a list was longer than n without swallowing more of the list than necessary. Is there something I misunderstood in the exchange ?
Yeah. The reference to the "lazy natural type", which is: data Nat = Zero | Succ Nat deriving (Eq, Ord, Read, Show) instance Num Nat where fromInteger 0 = Zero fromInteger (n + 1) = Succ (fromInteger n) etc. then genericLength xn > n does exactly what Andrew wants, when n :: Nat. Jonathan Cast http://sourceforge.net/projects/fid-core http://sourceforge.net/projects/fid-emacs