On Wed, Oct 28, 2015 at 5:52 PM, <galeonet@tiscali.it> wrote:
but if I write: [(x,y)|x<-[1..5],y<-[1..5],x<-[1]]
I obtain:
[(1,1),(1,2),(1,3),(1,4),(1,5),(1,1),(1,2),(1,3),(1,4),(1,5),(1,1),(1,2),(1,3),(1,4),(1,5),(1,1),(1,2),(1,3),(1,4),(1,5),(1,1),(1,2),(1,3),(1,4),(1,5)]

Others will chime in with a full answer soon.

Meanwhile, consider that

[(x,y)|x<-[1..5],y<-[1..5],x<-[1]]

(which is quite weird as a set-theoretic expression)

is Haskell-equivalent to

[(x,y)|_<-[1..5],y<-[1..5],x<-[1]]

Now consider

[(x,y)|y<-[1..5],x<-[1]]

which is [(1,1),(1,2),(1,3),(1,4),(1,5)] as you expect.

Separately, consider

[ a | _ <- [1..5], f a ]

where you can experiment with different values of f and a.

Putting together the pieces will give you an answer to your query.


-- Kim-Ee