Created
February 1, 2014 00:44
-
-
Save emadshaaban92/8746300 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
INDEX = 10001 | |
iter numbers = Iter.init(2, function(int elm){ elm + 1 }, function(int elm){ elm > 0 }) | |
function iter remove_multiples(int a, iter seq){ | |
Iter.filter(function(int elm){ mod(elm, a) != 0 }, seq) | |
} | |
function primes_init(iter seq){ | |
match(seq.next()){ | |
case {none} : { next : function () { none } } | |
case {some:it} : { next : function () { some((it.f1, primes_init(remove_multiples(it.f1, it.f2)))) } } | |
} | |
} | |
iter primes = primes_init(numbers) | |
option number = Iter.skip(INDEX - 1, primes).next() | |
jlog(Int.to_string(Option.get(number).f1)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment