Displaying 1 to 5 from 5 results

pun - A small library to enable pattern matching in javascript and coffeescript

  •    Javascript

A tiny functional programming library for Javascript/Coffeescript.

Functional Programming

  •    CSharp

This project brings some features from functional languages, like pattern matching, collection unfold or partial function application to C# and extends the possibilities of functional programming in C#. It's available as C# library.

funcy - An experiment in adding functional pattern matching to JavaScript

  •    Javascript

The above function implements a simple factorial function using pattern matching. When you call fact(10) the value ‘10’ is matched against the first pattern ‘0’. This match fails and the next pattern is evaluated. The ‘$’ in the next pattern is an example of a parameter. A parameter matches anything, so the match succeeds and ‘10’ is passed as an argument to the anonymous function. Since this is a recursive function it will match the second pattern until the argument to the function reaches zero and then terminates. Note that this example uses JavaScript ES6 syntax, code in previous JavaScript versions will be slightly more verbose. The fun method takes one or more pattern expressions and returns a function which, when called, will try to match the values passed to the patterns. If a match is found an anonymous function corresponding to the matched pattern is executed, and any extracted values passed to it as arguments.

MissMatch - Pattern matching for JavaScript inspired by one of the great features of the Haskell language

  •    Javascript

Powerful pattern matching for javascript. Can match any kind of javascript value against patterns, bind values and execute handlers when a pattern matches. Options are, well, optional. If provided they must be in the form of an object. The only supported option at the moment is arrow. If set to true bound parameters will be passed as arguments to handler functions instead of injected into their this context. This is required to support arrow functions because they do not have their own this context (or rather this inside an arrow function refers to the surrounding context).




tailored - A Pattern matching library for JavaScript

  •    Javascript

This is the pattern matching library ported from elixirscript. It allows you to create functions that will perform pattern matching on the input and either execute the corresponding function or throw a tailored.MatchError. tailored.defmatch(...clauses): Function - Takes one or more tailored.Clause objects and returns a pattern match function. It cycles through the clauses and if a corresponding pattern matches, and the guard is true, then the matching parameters are passed to the corresponding function that will execute. If no matching clause is found, a tailored.MatchError is thrown.