Recent snippets

  • A CONSOLE-BASED ROCK-PAPER-SCISSORS

    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: 9 hours ago by me

  • Get Bitcoin wallet

    76a9142220867b1e79c403fafe339a809a65ed01cb697988ac

    2 people like this

    Posted: 5 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.

    0 people like this

    Posted: 7 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: http://fssnip.net/a7 . 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: 9 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: 1 month ago by Faisal Waris

Popular snippets

  • Break sequence into n-element subsequences

    I'm working on parallel computations and I thought it would be useful to break work into chunks, especially when processing each element asynchronously is too expensive. The neat thing is that this function is general even though motivation for it is specific. Another neat thing is that this is true lazy sequence unlike what you'd get if you used Seq.groupBy. There are three versions for your enjoyment.

    71 people like this

    Posted: 9 years ago by Dmitri Pavlenkov

  • Adapter pattern

    Invoke the methods from incompatible types

    104 people like this

    Posted: 8 years ago by Tao Liu

  • Split a list

    Three ways to split a list in half (but not necessarily in the middle). A forth version added that's very short and should be fast, as we only use List.fold. New champ found.

    78 people like this

    Posted: 9 years ago by Dmitri Pavlenkov

  • get the list of LAN Sql servers

    get the list of ethernet sql servers

    89 people like this

    Posted: 9 years ago by nCdy

  • WPF / SilverLight Converter II

    version 1 is http://fssnip.net/62. This new version support convert from any existing function to a converter function by using composition and pipeline. The convert function is to make the function signature agree to the IValueConverter interface. You can add new functions in the FunctionLibrary module and reuse the class definition to reduce the coding effort. The first sample is to show how to make the converter pipeline work, the second one is a debugger converter used to debug the data binding problem.

    86 people like this

    Posted: 8 years ago by Tao Liu

  • Read only ref

    F# implementation of RO_ref from the "Effective ML" talk.

    82 people like this

    Posted: 9 years ago by fholm

Snippets by tags

html (15) async (95) design patterns (18) wpf (20) agent (20) recursion (31) list (53) tutorial (17) algorithms (25) regex (15) computation builder (14) reflection (18) kata (17) lists (14) collections (16) generic programming (16) fold (21) array (22) lazy (19) fparsec (15)

View all...

Database contains 2440 snippets out of which 1636 is public.