Last active
May 11, 2016 13:54
-
-
Save laparca/ebc3bdbfecf9e221cb663283cd18ae22 to your computer and use it in GitHub Desktop.
lazyness
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- for GHCi | |
let infinite_list = [1..] | |
let values = filter ((/= 0) . (`mod` 3)) $ filter ((/= 0) . (`mod` 2)) $ map (^2) infinite_list | |
take 10 values | |
-- Should be [1,25,49,121,169,289,361,529,625,841] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn main() { | |
let infinite_list = 1..; | |
let values = infinite_list | |
.map(|x| x*x) | |
.filter(|&x| x % 2 != 0) | |
.filter(|&x| x % 3 != 0) | |
.take(10); | |
for i in values { | |
println!("{}", i); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment