Roundcrisis

About Contact me Presentations rss feed  rss

Functional Katas Review Of Kata

15 Oct 2015

Functional Kats: Kata review

{highlight FSharp}

let isPrime x =
    match x with
    | 2 | 3 -> true
    | x when x % 2 = 0 -> false
    | _ ->
        let rec superPrimeCheck i =
            match i with
            | i when x % i = 0 -> false
            | i when x < i*i -> true
            | _ -> superPrimeCheck (i + 2)
        superPrimeCheck 3

isPrime 1
let oneM = 1000000
let checkStuff maxNumber =
            [2..10000]
            |> Seq.ofList
            |> Seq.filter(fun x-> isPrime x)
            |> Seq.fold(fun acc x ->                                                                                    
                            if (isPrime acc && acc <= maxNumber)then
                                printfn "found %A" acc
                            acc + x                            
                            ) 0
{endhighlight }

Choose sequences because:.

Categories:  

Want to discuss this post? the best place right now for me is mastodon, please message me @roundcrisis@types.pl with your comment or question.