Snippets in category Functional Languages

  • Haskell function : iterate

    Implements iterate function from Haskell's Prelude. The function generates an infinite sequence by applying a function to the initial value (first) and then to the result of previous application.

    102 people like this
    Posted: 1 years ago by Nick Palladinos

  • The Haskell const function

    The const function is simple, but you can use it to make your code more legible. In this example we convert a unary function to a function of arity 2 (that ignores the second argument). Also by using the flip function from Haskell (which is equally easy to define) you can ignore the first argument.

    55 people like this
    Posted: 1 years ago by Alex Muscar

  • Clojure's Atoms

    Clojure's Atoms are ref like structures, with the addition of (Compare And Swap) update semantics

    17 people like this
    Posted: 1 years ago by Nick Palladinos

  • Clojure's Atoms

    Clojure's Atoms are ref like structures, with the addition of (Compare And Swap) update semantics

    16 people like this
    Posted: 1 years ago by Nick Palladinos

  • Infinite sequences

    Haskell-inspired infinite sequences

    37 people like this
    Posted: 1 years ago by Nick Palladinos

  • A Clojure inspired (race free) memoize function

    A Clojure inspired (race free) memoize function, that uses a mutable atom cell.

    17 people like this
    Posted: 1 years ago by Nick Palladinos

  • Read only ref

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

    74 people like this
    Posted: 1 years ago by fholm

  • IronJS Boxing Struct

    This is the struct IronJS uses internally to do NaN-tagging of boxed values, using the technique described here http://blog.mozilla.com/rob-sayre/2010/08/02/mozillas-new-javascript-value-representation/ and here http://article.gmane.org/gmane.comp.lang.lua.general/58908

    8 people like this
    Posted: 1 years ago by fholm

  • Scheme interpreter in F#

    A small Scheme interpreter using Higher Order Abstract Syntax (HOAS) encoding for terms. The essence of the technique is to use F# (meta-level) functions to encode Scheme (object-level) functions and other binding constructs, thus avoiding the need for representing variables, bindings, explicit substitution and dealing with shadowing.

    17 people like this
    Posted: 1 years ago by Anton Tayanovskyy

  • Small embedded DSL to write in F# "Who is John Galt?"

    This snippet how we can use F# constructs like discrimated unions, functions and symbolic identifiers to represent proper language statements (albeit limited) using valid F# code.

    18 people like this
    Posted: 1 years ago by Horacio Nuñez

  • A Lazy fixed-point combinator

    x = f(x) encoded in F#

    14 people like this
    Posted: 1 years ago by Nick Palladinos