[Haskell-cafe] List comparisons and permutation group code

David House dmhouse at gmail.com
Thu Oct 19 16:38:04 EDT 2006


On 19/10/06, Brandon Moore <brandonm at yahoo-inc.com> wrote:
> isIdentity xs = xs == takeLengthOf xs [1..]
>  where takeLengthOf xs ys = zipWith const ys xs

You probably mean zipWith (flip const) xs ys.

> for finite lists,
> takeLengthOf xs ys == take (length xs) ys

This ruins the laziness again:

Hugs.Base> let takeLengthOf xs ys = take (length xs) ys; isIdentity xs
= xs == takeLengthOf xs [1..] in isIdentity (1:3:2:[4..10000])
False
(210064 reductions, 278075 cells)
Hugs.Base> let takeLengthOf = zipWith (flip const); isIdentity xs = xs
== takeLengthOf xs [1..] in isIdentity (1:3:2:[4..1000])
False
(60 reductions, 114 cells)

-- 
-David House, dmhouse at gmail.com


More information about the Haskell-Cafe mailing list