[Haskell-begin] Alternating sequence
Dirk Markert
dirk.markert at gmail.com
Mon Jul 21 11:55:10 EDT 2008
Hi Felipe,
very nice simplification. Now I can even recognize the pattern used in the
fibonacci number solution.
Thanks,
Dirk
2008/7/21 Felipe Lessa <felipe.lessa at gmail.com>:
> On Mon, Jul 21, 2008 at 11:21 AM, Bernie Pope <bjpop at csse.unimelb.edu.au>
> wrote:
> > suffix = 5 : [ x + y | (x,y) <- zip suffix (cycle [2,4])]
> > list = 2 : 3 : suffix
>
> 'suffix' can be simplified a bit by using zipWith:
>
> suffix = 5 : zipWith (+) suffix (cycle [2,4])
>
>
> Thanks,
>
> --
> Felipe.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/beginners/attachments/20080721/d185ba25/attachment.htm
More information about the Beginners
mailing list