Snippets tagged pattern matching

  • Filtering lists

    Two functions showing how to filter functional lists using the specified predicate. First version uses naive recursion and the second one is tail-recursive using the accumulator parameter.

    76 people like this

    Posted: 14 years ago by Tomas Petricek

  • Active pattern for let binding inside patterns

    The Let active pattern demonstrated by this snippet can be used to assign values to symbols in pattern matching. This is useful for writing complex pattern matching using match as we can handle multiple cases using a single clause.

    64 people like this

    Posted: 14 years ago by Tomas Petricek

  • DSL for detecting patterns in 2D

    A simple domain specific langauge (DSL) that can be used to specify and recognize patterrns in 2D arrays. A pattern is defined by composing primitive checks, rotating and translating patterns. See also: http://t.co/6Poty4FL

    3 people like this

    Posted: 12 years ago by Tomas Petricek

  • FizzBuzz with Rule Engine

    Inspired by http://dave.fayr.am/posts/2012-10-4-finding-fizzbuzz.html Rules are in a list of lambdas that can be easily modified. A pattern-matching recursive function applies them in the correct order.

    7 people like this

    Posted: 12 years ago by Richard Broida

  • Different styles of pattern matching

    For tutorial, the same functionality, different styles of pattern matching.

    4 people like this

    Posted: 10 years ago by Tuomas Hietanen

  • REST For Free

    HttpListener + FParsec + Pattern Matching = Simple REST Endpoints

    3 people like this

    Posted: 9 years ago by Ted Cackowski Jr

  • Coord

    Playing with coordinates and moves See https://github.com/giuliohome/AdventOfCode2019/blob/master/Day15-Part1-QueueVersion.fs#L54-L66

    1 people like this

    Posted: 5 years ago by giuliohome

  • Functional wrappers for TryParse APIs

    Exemplary convenience wrappers for some of the System..TryParse APIs, using the combined power of F#' return value deconstruction mechanism via pattern matching, active patterns and option types instead of "out/ref" parameters. Added support for newest versions of F# to determine which overload of TryParse should be used.

    0 people like this

    Posted: 29 days ago by Cody