(def numbers [1 2 3 4 5]) ; => [1 2 3 4 5]
; conj (short for conjoin) is a function that can take a vector and arguments, appends arguments to vector
(conj numbers 6) ; => [1 2 3 4 5 6]
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
curl http://en.wikipedia.org/w/api.php\?action\=query\&format\=txt\&list\=categorymembers\&cmtitle\=Category:21st-century_American_singers\&cmlimit\=500 | grep title | sed 's/\[title\] => //' | xargs -L1 echo "Taylor Swift > " |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var tinytic = require('tinytic'); | |
function render (dT) { | |
// ... | |
} | |
function loop() { | |
requestAnimationFrame(loop); | |
var dT = tinytic.toc(); | |
render(dT); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for dest in /**/*; do whoami | say; done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var _ = new Proxy({}, { | |
get: function get(target, property) { | |
return function f(x) { | |
return x[property](); | |
} | |
} | |
}); | |
["some", "words"].map(_.toUpperCase); // => ["SOME", "WORDS"]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'compose' from 'fnal'; | |
export default function IO(fn){ | |
return { | |
fmap: function(mapFn) { | |
return IO(compose(mapFn, fn)); | |
}, | |
performUnsafeIO: function(){ | |
return fn(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class BaseClass { | |
constructor() { | |
this.mixins.forEach(mixin => mixin(this)); | |
} | |
} | |
// then either | |
class x extends BaseClass { | |
constructor() { | |
this.mixins = [observable, whatever]; | |
super(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function clone(obj) { | |
if (Array.isArray(obj)) { | |
return obj.slice(0); | |
} | |
if (typeof obj === 'object') { | |
return Object.keys(obj).reduce(function(clone, key) { | |
clone[key] = obj[key]; | |
return clone; | |
}, {}); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function State(value, state){ | |
if(!(this instanceof State)) { | |
return new State(value); | |
} | |
this.__value__ = value; | |
this.__state__ = state || {}; | |
} | |
State.prototype.fmap = function(fn) { | |
var state = Object.assign({}, this.__state__); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function compose(f, g) { | |
return function(x) { | |
return f(g(x)); | |
} | |
} | |
function cons(arr) { | |
return function (val) { | |
return arr.concat(val); | |
} |