I am new in F# and I am just wondering if is there any way to get lazy sequence of prime numbers in F#.
In Haskell I use next code:
primes :: [Integer]
primes = sieve[2..]
where sieve (p:xs) = p : sieve [x | x <- xs, x `mod` p > 0]
In F# I can check if is the number is prime:
let isPrime (number : bigint) =
match number with
| _ -> seq { bigint(2) .. bigint(Math.Sqrt(float number))}
|> Seq.exists (fun x -> if (number % x = bigint(0)) then true else false)
|> not
But I don't know how to convert it to lazy sequence.