diogodadalt / alonzo

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

    ___    __                            _     
   /   |  / /___  ____  ____  ____      (_)____
  / /| | / / __ \/ __ \/_  / / __ \    / / ___/
 / ___ |/ / /_/ / / / / / /_/ /_/ /   / (__  ) 
/_/  |_/_/\____/_/ /_/ /___/\____(_)_/ /____/  
                                  /___/     

Overview

Alonzo.js is intended to provide functional features to JavaScript. It was created initially to exercise the functional paradigm concepts along with Ecmacript 6 and for my personal use. But feel free to give it a try.

Examples

Currying

var add = function(a, b) { return a + b; },
	fun = lib.Alonzo().curry(add),
	partialAnswer = fun(1),
	answer = partialAnswer(2);

Composition

var add = function(a, b) { return a + b; },
	multiplyBy3 = function(a) { return a * 3; },
	fun = lib.Alonzo().compose(multiplyBy3, add),
	answer = fun(1, 2);
Tuples
var tuple = lib.Alonzo().tuple('some string', {a: '', b: 2});
console.log(tuple._1); // 'some string'
console.log(tuple._2); // {a: '', b: 2}

About


Languages

Language:JavaScript 100.0%