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 PalladinosThe 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 MuscarClojure'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 PalladinosClojure'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 PalladinosInfinite sequences
Haskell-inspired infinite sequences
37 people like this
Posted: 1 years ago by Nick PalladinosA 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 PalladinosRead only ref
F# implementation of RO_ref from the "Effective ML" talk.
74 people like this
Posted: 1 years ago by fholmIronJS 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 fholmScheme 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 TayanovskyySmall 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ñezA Lazy fixed-point combinator
x = f(x) encoded in F#
14 people like this
Posted: 1 years ago by Nick Palladinos
Lexer
Hand-written efficient JavaScript lexer from the IronJS project https://github.com/fholm/IronJS
16 people like this
Posted: 1 years ago by fholmHosting the DLR with IronPython or Ruby
Definition of the dynamic resolution operators for hosting the DLR. You can either use Ruby or Python, as the module isn't language specific.
3 people like this
Posted: 1 years ago by Rainer SchusterFunctor => Applicative => Monad
Yet another attempt of mine to "haskellify" my F# coding.
8 people like this
Posted: 1 years ago by Nick PalladinosML style module example
ML style module example
1 people like this
Posted: 1 years ago by fholmActors acting as Lambdas
The Untyped Lambda Calculus encoded as actors (F#'s MailboxProcessors)
2 people like this
Posted: 1 years ago by Nick PalladinosFunctions not so first class in active patterns
It seems that you can't pass anonymous functions as parameters to active patterns.
3 people like this
Posted: 11 months ago by Kurt SchelfthoutNorvig's Spelling Corrector
A line-by-line translation of Norvig's original Python code. An attempt to view F# as a "typed" Python.
4 people like this
Posted: 10 months ago by Nick PalladinosScrap Your Boilerplate
Scrap Your Boilerplate with the help of F#. Based on the original paper by Ralf Laemmel and Simon Peyton Jones.
6 people like this
Posted: 8 months ago by Nick PalladinosPolyvariadic fixpoint
Polyvariadic fixpoint combinator in F# (heavily inspired by Haskell)
2 people like this
Posted: 5 months ago by Nick PalladinosHaskell to F# (some operators)
Just toying around with making my F# code a little smaller with Haskell operators
4 people like this
Posted: 2 months ago by Cameron FrederickScrap Your Boilerplate (with class)
A typecast free experiment in Generic Programming. Inspired by "Scrap Your Boilerplate (with class)".
4 people like this
Posted: 10 days ago by Nick Palladinos