Handy F# snippets

code-snippets, f#, reference

Solution

Perl style regex matching

let (=~) input pattern =
    System.Text.RegularExpressions.Regex.IsMatch(input, pattern)

It lets you match text using `let test = "monkey" =~ "monk.+"` notation.

Problem

There are already two questions about F#/functional snippets. However what I'm looking for here are useful snippets, little 'helper' functions that are reusable. Or obscure but nifty patterns that you can never quite remember. Something like: ``` open System.IO let rec visitor dir filter= seq { yield! Directory.GetFiles(dir, filter) for subdir in Directory.GetDirectories(dir) do yield! visitor subdir filter} ``` I'd like to make this a kind of handy reference page. As such there will be no right answer, but hopefully lots of good ones. EDIT Tomas Petricek has created a site specifically for F# snippets http://fssnip.net/.

Original source

Related problems