
24 Mar
2009
24 Mar
'09
8:04 p.m.
Jake McArthur ha scritto:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
Manlio Perillo wrote: | This is right. | The problem is that often (IMHO) a function definition can be rewritten | so that it is much more readable. | | As an example, with the takeList function I posted.
I looked at it, found nothing wrong with the original, and absolutely hated your "fixed" version.
With the original version, you have to "follow" 3 separate operations: Prelude> let xs = [1, 2, 3, 4] :: [Int] Prelude> let ns = [3, 1] :: [Int] Prelude> let _1 = scanl (flip drop) xs ns Prelude> let _2 = init _1 Prelude> let _3 = zipWith take ns _2 With my function, instead, you only have to "follow" 1 operation: Prelude> (head, tail) = splitAt n xs
[...]
Manlio