私は F# を使い始めたばかりで、Problem Euler problem #3 を試しています。素数を見つけるために、最大数までのすべての素数を計算する次のコードを思い付きました。
let rec allPrimes foundPrimes, current, max =
// make sure the current number isn't too high
// or the current number isn't divisible by any known primes
if current >= max then
foundPrimes
else
let nextValue = current + 1
if not List.exists (fun x -> current % x = 0L) foundPrimes then
allPrimes foundPrimes nextValue max
else
allPrimes (foundPrimes :: current) nextValue max
残念ながら、これによりエラーが発生します。
'let rec' コンストラクトでバインドできるのは、単純な変数パターンのみです。
このエラーが発生するのはなぜですか?