This file contains hidden or 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 fac = let | |
facImpl = \n, sum -> | |
(n ? ['fac', n - 1, n * sum] : ['done', sum]), | |
trampoline = \k -> { | |
while (true) { | |
switch (k[0]) { | |
case 'done': return k[1]; | |
case 'fac': k = facImpl(k[1], k[2]); break | |
} |
This file contains hidden or 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
model.location.subscribe(\current -> { | |
if (current && current.start) | |
cm.removeLineClass(current.start.line - 1, 'background', 'active-line'); | |
}, null, 'beforeChange'); | |
model.location.subscribe(\x -> { | |
if (x) | |
cm.addLineClass(x.start.line - 1, 'background', 'active-line'); | |
}); |
This file contains hidden or 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 _ = {}; | |
var placeholder = function(f /*, ...*/) { | |
var bound = [].slice.call(arguments, 1); | |
return function(/*...*/) { | |
var indx = 0; | |
return f.apply(f, [].reduce.call(arguments, function(p, c) { | |
while (indx in bound) { | |
var val = bound[indx]; | |
if (val === _) |
This file contains hidden or 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 transactionalTryStatement = function(body, handlerId, handler, finalizer) { | |
return bind(getState, function(state) { // Get the current state. | |
return tryStatement( // Then evaluate a try statement with an exception handler that | |
body, // restores the saved state and executes the passed in handler. | |
handlerId, | |
next(setState(state), handler), | |
finalizer); | |
}); | |
}; |
This file contains hidden or 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 range(start, end) { | |
var indicies = [], out = []; | |
for (var i = start; i < end; ++i) | |
indicies.push(i); | |
while (indicies.length) { | |
var index = Math.floor(Math.random() * indicies.length); | |
out.push(indicies[index]); | |
indicies.splice(index, 1); | |
} | |
return out; |
This file contains hidden or 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
/*------------------------------------------------------------------------------ | |
Common list operations (map, foldl, foldr) for C++ tuples. | |
Depends on Cons, Car, and Cdr for tuples from: https://gist.github.com/mattbierner/6145505 | |
------------------------------------------------------------------------------*/ | |
#include "tuple_ops.h" | |
/* Impl --------------------- */ |
This file contains hidden or 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
#include "tuple_ops.h" | |
template<typename T> | |
void print_tuple(const T& x) | |
{ | |
std::cout << "Head:" << Car(x) << " Remaining:" << std::tuple_size<T>::value - 1 << std::endl; | |
} | |
int main(int argc, const char* argv[]) | |
{ |
This file contains hidden or 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 reduce = Function.prototype.call.bind(Array.prototype.reduce); | |
var trie = (function(){ | |
var wordReduce = function(parent, l) { | |
return (parent[l] = (parent[l] || {})); | |
}; | |
var wordsReduce = function(trie, word) { | |
var node = reduce(word, wordReduce, trie); | |
node[''] = null; | |
return trie; |
This file contains hidden or 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
#!/bin/sh | |
# Minify js files | |
COMPILER="java -jar compiler.jar" | |
OPTIONS="--compilation_level=ADVANCED_OPTIMIZATIONS" | |
SRC=lib | |
DEST=dist |
This file contains hidden or 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
// Source generator for fibonacci sequence | |
function fibonacci() { | |
var c = 0, d = 1; | |
return function(y, b) { | |
var next = c; | |
c = d; | |
d = next + d; | |
return y(next); | |
}; | |
} |