2

Is there a was to make a function in F# working for each type of number. I would like to pass in a number of a type and get the same type back.

Here a short example:

let Primes max=
    let rec loop primes acc=
        match acc with
        |x::xs ->   let filtered = acc |> List.filter (fun y -> y%x <> 0)
                    loop (x::primes) filtered
        |[] -> primes |> List.rev
    loop [] [2..max]

Now I can only pass in int32, but I want to pass in uint64 or bigint if necessary.

Cooki3Tube
  • 107
  • 1
  • 10
  • 1
    Check this question - [How to write a function for generic numbers?](http://stackoverflow.com/questions/4732672/how-to-write-a-function-for-generic-numbers) It covers the topic in more detail than one would ever need. – scrwtp Jan 30 '16 at 19:28
  • Tank you for the quick reply :D – Cooki3Tube Jan 30 '16 at 20:06

0 Answers0