Skip to content

Instantly share code, notes, and snippets.

@dhruvchandna
dhruvchandna / javascript-closures-filter-dsl
Last active December 20, 2015 23:39
Closures in Javascript to create a mini DSL to filter arrays.
var _some = Array.prototype.some;
var _every = Array.prototype.every;
function lessThan(x){
return function(y){
return y < x;
};
}
function greaterThan(x){
return function(y){
@dhruvchandna
dhruvchandna / gist:1821384
Created February 13, 2012 23:19
Seven Languages In Seven Weeks: Erlang: Day2: Ex1
% Function that takes in a keyword and list of the form
% [{ruby,"an OO language"}, {erlang,"a functional language"}]
% and returns the associated value for the keyword.
Value = fun(X,L) -> [Y || {Z,Y} <- L, X=:=Z] end.