[Haskell-beginners] lists strange behaviour

galeonet at tiscali.it galeonet at tiscali.it
Wed Oct 28 10:52:53 UTC 2015


Hello,
if I write down: [(x,y)|x<-[1..5],y<-[1..5]]
I obtain as expected:
[(1,1),(1,2),(1,3),(1,4),(1,5),(2,1),(2,2),(2,3),(2,4),(2,5),(3,1),(3,2),(3,3),(3,4),(3,5),(4,1),(4,2),(4,3),(4,4),(4,5),(5,1),(5,2),(5,3),(5,4),(5,5)]
If I write down: [(x,y)|x<-[1..5],y<-[1..5],x==5]
I obtain as expected:
[(1,1),(1,2),(1,3),(1,4),(1,5)]
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)]
Why?????
Thank you in advance.
Regards,
Maurizio


Connetti gratis il mondo con la nuova indoona:  hai la chat, le 
chiamate, le video chiamate e persino le chiamate di gruppo.
E chiami gratis anche i numeri fissi e mobili nel mondo!
Scarica subito l’app Vai su https://www.indoona.com/




More information about the Beginners mailing list