于 11-8-23 下午11:37, Ivan Lazar Miljenovic 写道:
It might not be what_you_  want, but it might be what others want.  If
you're concerned with efficiency, then wouldn't you use length rather
than genericLength?

length is identical to genericLength in ListLike except type signature.
but still,
import Data.Number
import Data.List
import qualified Data.ListLike as L
(3 :: Natural) < genericLength [1..] (work)
(3 :: Natural) < L.genericLength [1..] (non-terminating)

If you want laziness, L.genericLength should be defined like this
L.genericLength [] = 0
L.genericLength (_:l) = 1 + L.genericLength l
the genericLength used in ListLike package used tail recursion while non-strict. and also, a strict length is still needed (currently, length is identical to genericLength)

Thank you
bob

_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to