Static extension methods on Seq module
To extend an F# module, just create another module with the same name: module Seq = let myMap f s = seq { for x in s do yield f x } Seq. // see your stuff here alongside normal stuff
To extend an F# module, just create another module with the same name: module Seq = let myMap f s = seq { for x in s do yield f x } Seq. // see your stuff here alongside normal stuff
I’m in the same boat as you, doing lots and lots of line-of-business type apps, nothing “fun” like games or compilers or search engines. Your mileage will vary, but at least in my own experience a lot of dev teams are reluctant to jump right into F# because no one else on the team knows … Read more
The access specifier of the primary constructor follows the name and type parameters of the type: type ValidString private (value: string) = …
What about: abstract member createEmployee : firstName:string -> lastName:string -> Employee ?
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
You should definitely check out http://research.microsoft.com/en-us/um/cambridge/projects/fsharp/manual/FSharp.PowerPack/Microsoft.FSharp.Collections.LazyList.html but I will try to post a more comprehensive answer later. UPDATE Ok, a solution is below. It represents the Morris sequence as a LazyList of LazyLists of int, since I presume you want it to be lazy in ‘both directions’. The F# LazyList (in the FSharp.PowerPack.dll) has three … Read more
If you want it to be very pretty, you could steal about 25 lines of code from this blog entry to draw it with WPF. But I’ll code up an ascii solution shortly too, probably. EDIT Ok, wow, that was hard. I’m not certain it’s entirely correct, and I can’t help but think there’s probably … Read more
if you consider that not is also a function, then you can pipe your condition into it to avoid parenthesis like so: if not <| condition param1 param2 then … reason being is if your condition function takes arguments, you don’t need to do not (condition param1 param2) it’s probably a little cleaner to do … Read more
Actually, you can add folders to F# projects but it’s not supported directly through Visual Studio (you have to edit the project file yourself): http://fsprojectextender.codeplex.com/ (edit: old link was broken, updated to F# Project Extender home page which has links to the original blog posts which were moved) (which I found in this answer). I … Read more
As always, continuations yield an elegant tailcall solution: open System.Collections.Generic let cache = Dictionary<_,_>() // TODO move inside let memoizedTRFactorial = let rec fac n k = // must make tailcalls to k match cache.TryGetValue(n) with | true, r -> k r | _ -> if n=0 then k 1 else fac (n-1) (fun r1 … Read more