[clean-list] where clause and list comprehensions

John van Groningen johnvg at cs.ru.nl
Wed Oct 5 14:11:01 MEST 2005


Valéry wrote :
>Consider for instance :
>l p = [f x \\ x <- [1..] | (f x) rem 2 == 0 &&  p (f x)]
>Is there some way to define y = f x once instead of 3 times ?

Yes, this was added in Clean 2.1.1:

l p = [	y \\ x <- [1..],
             let y = f x
             | f x rem 2 == 0 && p y
      ]

Regards,

John van Groningen



More information about the clean-list mailing list