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
let FactorialContinuation{val cust}< | |
case \arg: send val ('*' arg cust) ; | |
> | |
let Factorial < | |
case 0 \cust: send cust (1) ; | |
case \val \cust: | |
send val ('-' 1 < | |
case \result: | |
send Factorial (result FactorialContinuation{val cust}) |
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
ssf.format("Hello @", "world") -> "Hello world" | |
// Formatting from an object. | |
ssf.format("Member['a']:@a Member['c']['d']:@c.d", {'a':1, 'c': {'d': 2}}) | |
-> "Member['a']:1 Member['c']['d']:2" | |
// Formatting from an array. | |
ssf.format("Array[0]:@0 Array[1]:@1", ['A', 3]) -> "Array[0]:A Array[1]:3" |
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 t = sssf.compile("@s(:[1,])"); | |
t('abc') -> 'bc' | |
t({}) -> 'object Object]' |
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
// Call notation | |
var slice = callable.callable(Array.prototype.slice); | |
slice([1, 2, 3, 4], 1, 3) -> [2, 3] | |
// Apply notation | |
var slicea = callable.applicable(Array.prototype.slice); | |
slicea([1, 2, 3, 4], [1, 3]) -> [2, 3] | |
// Call notation binding leading arguments | |
var sliceb = callable.callable(Array.prototype.slice, 1); |
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
// 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); | |
}; | |
} |
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
#!/bin/sh | |
# Minify js files | |
COMPILER="java -jar compiler.jar" | |
OPTIONS="--compilation_level=ADVANCED_OPTIMIZATIONS" | |
SRC=lib | |
DEST=dist |
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 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 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 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 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; |
OlderNewer