[Haskell-begin] Alternating sequence

Felipe Lessa felipe.lessa at gmail.com
Mon Jul 21 10:24:01 EDT 2008


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.


More information about the Beginners mailing list