[Haskell-beginners] How would you write...

John M. Dlugosz ngnr63q02 at sneakemail.com
Tue Apr 22 18:30:15 UTC 2014


On 4/22/2014 3:47 AM, Frerich Raabe wrote:

>
>    chain1 = [ translate x y $ color red $ Circle r | i <- [1..10], (x,y,r) <- pappus 100 i ]
>
> would be one way to do what you want.
>

Yes, that's along the lines of what I was thinking — the 1..10 needs to be bound by itself 
to trigger the looping behavior, but didn't know how to then continue to generate (x,y,r). 
  I thought the comma there was followed by a "guard", which constrains which values of i 
are taken or skipped.  Ah, you have a <- there too.  Hmm, but normally a second <- is 
another iteration that's done first/loops faster.  So what's the syntax here?  I must be 
getting things mixed up.

—John



More information about the Beginners mailing list