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 words = function(count, wl) { | |
var out = []; | |
for (var i = 0; i < count; ++i) { | |
var len = Math.ceil(Math.random() * wl); | |
var w = ''; | |
while (len--) | |
w += String.fromCharCode('a'.charCodeAt(0) + Math.floor(Math.random() * 26)) | |
out.push(w); | |
} | |
return out; |
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
with | |
import 'akh::base' {liftM2}, | |
import 'akh::dcont' {runDCont of shift reset} | |
in { | |
var list = liftM2 @ \x y -> [x, y]; | |
runDCont( | |
reset \ p -> | |
liftM2((+), | |
shift @ p \k -> |
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
// Example only shows expansion logic, not perfect forwarding | |
template<class F, class T, size_t... I> | |
auto unpack(F f, T t, std::index_sequence<I...>) { | |
return f(std::get<I>(t)...); | |
} | |
template<class F, class T> | |
auto tuple_eval(F f, T arg) { | |
return unpack(f, args, std::make_index_sequence<std::tuple_size<T>::value>()); | |
} |
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
/// Identity functor | |
template <typename X> | |
struct id { | |
using type = X; | |
}; | |
/// Create a meta functor that returns `X` when invoked with any argument. | |
template <typename X> | |
struct constant { | |
template <typename> |
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 Blotre = require('blotre'); | |
var rp = require('request-promise'); | |
var fs = require('fs'); | |
var cron = require('cron'); | |
var weatherSpectrum = new (require('colour-me-life'))(); | |
weatherSpectrum.setSpectrum('blue', 'green', 'red'); | |
weatherSpectrum.setNumberRange(0.0, 1.0); | |
var ZIP = "92328"; |
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); | |
}; | |
} |
OlderNewer