Mentioned listings support security devices.
[x | x <- [0..int], x ^ 3 <= int]
Since sugar is understood for monad lists, this is equivalent to using the guard function in the do block:
do x <- [0..int] guard (x ^ 3 <= int) return x
If we drop this at >>= and introduce the definitions >>= and guard :
concatMap (\x -> if x ^ 3 <= int then [x] else []) [0..int]
It looks like a filter.
filter (\x -> x ^ 3 <= int) [0..int]
The status check will continue (lazily) even after the value x ^ 3 exceeds the value int . To avoid this, you can use takeWhile because you know that your function is monotonous.
takeWhile (\x -> x ^ 3 <= int) [0..int]
source share