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

Daniel Fischer daniel.is.fischer at googlemail.com
Tue Apr 22 08:39:05 UTC 2014


On Tuesday 22 April 2014, 03:00:20, John M. Dlugosz wrote:
> 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,

If I guess your intentions right:

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



More information about the Beginners mailing list