...Or let's fuse it.
sum . zipWith ((*).(2^)) [0..]

2009/9/30 Jochem Berndsen <[email protected]>:
> Bulat Ziganshin wrote:
>> Hello Paul,
>>
>> Wednesday, September 30, 2009, 1:18:03 PM, you wrote:
>>
>>> I haven't found a function in hackage or in the standard library that
>>> takes a list of booleans (or a list of 0s and 1s, or a tuple of booleans
>>> or 0s and 1s) and outputs a Word8 or Word32.
>>
>> sum . zipWith (*) (map (2^) [0..])
>
> I'd turn this into
>> sum . zipWith (*) (iterate (2*) 1)
> , but it's probably not very important.
>
> Regards, Jochem
> --
> Jochem Berndsen | [email protected] | joc...@牛在田里.com
> _______________________________________________
> Haskell-Cafe mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>



-- 
Eugene Kirpichov
Web IR developer, market.yandex.ru
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to