Does F# have generic arithmetic support?

As brian mentioned, there is some built-in support for generic arithmethic and you can use ‘static constraints’ which allow you to define some generic functions yourself (although this is a bit limited). In addition to this, you can also use dynamic ‘numeric associations’, which is a bit slower when using in a function, but it … Read more

F# extension methods in C#

[<System.Runtime.CompilerServices.Extension>] module Methods = [<System.Runtime.CompilerServices.Extension>] let Exists(opt : string option) = match opt with | Some _ -> true | None -> false This method could be used in C# only by adding the namespace (using using) to the file where it will be used. if (p2.Description.Exists()) { …} Here is a link to the … Read more

F# development and unit testing? [closed]

Test-driven developers should feel right at home in functional languages like F#: small functions that give deterministically repeatable results lend themselves perfectly to unit tests. There are also capabilities in the F# language that facilitate writing tests. Take, for example, Object Expressions. You can very easily write fakes for functions that take as their input … Read more

F# getting a list of random numbers

Your code is simply getting one random number and using it ten times. This extension method might be useful: type System.Random with /// Generates an infinite sequence of random numbers within the given range. member this.GetValues(minValue, maxValue) = Seq.initInfinite (fun _ -> this.Next(minValue, maxValue)) Then you can use it like this: let r = System.Random() … Read more

Correct version of Fsharp.Core

You should not be obtaining FSharp.Core from nuget. Microsoft does not publish any official F# bits to nuget today (though this could potentially change in the future). It’s common for 3rd-party packages to bundle FSharp.Core (since presumably that’s the version used for testing/validation of that 3rd-party component), but nuget should not currently be used as … Read more