Skip to content

Instantly share code, notes, and snippets.

@monkyz
monkyz / gist:3935315
Created October 22, 2012 23:04
javascript boolean logic
// => means:"evaluates into"
true && true => true;
true && false => false;
false && true => false;
false && false => false
-----------------------------------------------------------------------------------------------------------
false || false => false;
true || false => true;
false || true => true;
@monkyz
monkyz / gist:4695747
Created February 2, 2013 02:15
nasty code
function addThree(x) {return x + 3;};
function composed(func) {
return function(x) {
return func(func(x))
}
};
composed(addThree)(4);
/*
I've wrapped Makoto Matsumoto and Takuji Nishimura's code in a namespace
so it's better encapsulated. Now you can have multiple random number generators
and they won't stomp all over eachother's state.
If you want to use this as a substitute for Math.random(), use the random()
method like so:
var m = new MersenneTwister();