[Haskell-cafe] about Haskell code written to be "too smart"
Eugene Kirpichov
ekirpichov at gmail.com
Tue Mar 24 15:33:15 EDT 2009
Pretty cool once you know what the function does, but I must admit I
wouldn't immediately guess the purpose of the function when written in
this way.
2009/3/24 Miguel Mitrofanov <miguelimo38 at yandex.ru>:
>> | 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. I might have written it like this, instead:
>>
>> ~ buildPartitions xs ns = zipWith take ns . init . scanl (flip drop)
>> xs $ ns
>
> Maybe it's just me, but I think that
>
> takeList ns xs = evalState (mapM (State . splitAt) ns) xs
>
> or even
>
> takeList = evalState . map (State . splitAt)
>
> would be much clearer than both versions.
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
--
Eugene Kirpichov
Web IR developer, market.yandex.ru
More information about the Haskell-Cafe
mailing list