-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Manlio Perillo wrote:
| 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

I think you are way oversimplifying your own code.

~    takeList :: [Int] -> [a] -> [[a]]
~    takeList [] _         =  []
~    takeList _ []         =  []
~    takeList (n : ns) xs  =  head : takeList ns tail
~        where (head, tail) = splitAt n xs

In order to understand this, I have to look at three different cases, an
uncons, a splitAt, a cons, *and* a recursive call. This is *seven*
different things I have to absorb.

- - Jake
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAknJQ1MACgkQye5hVyvIUKl+hQCfc7Yd8mi8uXDRTZQa11Pn8zeT
cZMAnApAcI+pr0wpYUP6Z0jHQ2vtf0ze
=Z5ze
-----END PGP SIGNATURE-----
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to