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

John M. Dlugosz ngnr63q02 at sneakemail.com
Tue Apr 22 08:00:20 UTC 2014


chain1 = [ translate x y $ color red $ Circle r | (x,y,r) <- pappus 100 [1..10] ]

The above is not right, as the comprehension syntax doesn't see the input range buried in 
an argument.

What's the right way to express

pap1 = translate x y $ color red $ Circle r
  where (x,y,r) = pappus 100 1

where 1 is [1..10] and I get a list of results?
(pap1 does work as expected)

(1) how can the list comprehension syntax manage it,
(2) what's the recommended way to express that (not necessarily via list comprehension 
syntax) ?

—John



More information about the Beginners mailing list