Recent snippets


    When playing rock-paper-scissors (RPS), we show 0 fingers for rock, 2 for scissors and 5 for paper. This rule is also applied for this console-based game written in F#. Enjoy !

    0 people like this

    Posted: 6 days ago by me

  • Get Bitcoin wallet


    2 people like this

    Posted: 12 days ago by The streets

  • [HELP!] How to separately compile a function in F# at RUN-TIME ?

    Hello everyone, I'm a student who's programed with F# for 8 months. With F#, I managed to write an interpreter for my own language. By using higher order functions and abstract syntax tree, my interpreter can turn the whole program written by programmers (in the form of a string[]) into a single unit->unit function which actually runs (exactly) what programmers wrote in the string[]. The thing is I'd like to know if there are ways to compile/ convert a function into a .exe file. If someone's willing to help me, feel free to leave a comment by editing this snipet. /// Please note that I'm asking how to compile a function (can be unit or unit->unit) at RUN-TIME. Thank you in advance. /// Oh, by the way, I left the link to the source code of my interpreter. This may be useful for you to help me. /// Please, just don't laught at my interpreter and the way I wrote it.

    1 people like this

    Posted: 13 days ago by A Person Trying To Sharpen His Programming with F# Everyday

  • Send HTTP Post Request (Handling error info)

    Based on Tomas Petricek's: . Shows how to handle non OK (200) response codes, where .Net raises an exception upon GetResponse(), which makes it difficult to recover further error information. Here the snippet shows how to handle errors wrapping a Result type.

    2 people like this

    Posted: 16 days ago by Joan Arnaldich

  • .NET Core 3 Windows Service

    With .NET Core 3 a template 'dotnet new worker' was created that allows services to be created. The template currently only works to create C# code so this snippet shows how I have translated the C# into F# and the steps needed to create the service. dotnet new console -lang F# -o FsharpService cd FsharpService dotnet add package Microsoft.Extensions.Hosting.WindowsServices dotnet add package System.Net.NameResolution Update the program.fs as shown below and then build and install the service dotnet publish -r win-x64 -c Release /p:PublishSingleFile=true /p:PublishTrimmed=true -o "./published" sc create fSharpService binPath= "<>\FsharpService.exe"

    3 people like this

    Posted: 1 month ago by Jackson McCann

  • Useful operator definition for interop with C#

    invokes op_Implicit when applied (for implicit conversions). I have found this to be very convenient when using C# libraries

    6 people like this

    Posted: 2 months ago by Faisal Waris

Popular snippets

  • Struct Tuple

    Two/Three/Four-element generic tuples implemented as a value types for writing more efficient F# code.

    59 people like this

    Posted: 9 years ago by fholm

  • Continuation-Passing Mnemonics

    Continuations provide a means whereby heap space can be traded for stack depth (heap space being generally more plentiful than stack depth). They are especially useful where tail recursion is not possible. Here are a couple of simple continuation examples that can be extended to cover more complex scenarios.

    89 people like this

    Posted: 9 years ago by Neil Carrier

  • Units of Measure

    Show's how to define units of measure to add stronger typing to your numerical functions.

    75 people like this

    Posted: 9 years ago by Robert Pickering

Snippets by tags

game (31) silverlight (22) regex (15) learning f# (16) collections (16) generic programming (16) array (22) html (15) lists (14) seq (54) wpf (20) web (27) tryfsharp (48) fold (21) dsl (23) staging (18) algorithms (25) sequences (47) fparsec (15) recursion (31)

View all...

Database contains 2445 snippets out of which 1636 is public.