just use GHC for OSX https://ghcformacosx.github.io
the rest of these directions are preserved for historical purposes
xcode-select --install ; brew tap homebrew/versions ; brew tap homebrew/dupes \
just use GHC for OSX https://ghcformacosx.github.io
the rest of these directions are preserved for historical purposes
xcode-select --install ; brew tap homebrew/versions ; brew tap homebrew/dupes \
function varIntBytes(v) { | |
const r = [v & 0x7f] | |
while ((v >>= 7) > 0) { | |
r.unshift(0x80 + (v & 0x7f)) | |
} | |
return r | |
} |
/* chacha20 - 256 bits */ | |
// Written in 2014 by Devi Mandiri. Public domain. | |
// | |
// Implementation derived from chacha-ref.c version 20080118 | |
// See for details: http://cr.yp.to/chacha/chacha-20080128.pdf | |
function U8TO32_LE(x, i) { | |
return x[i] | (x[i+1]<<8) | (x[i+2]<<16) | (x[i+3]<<24); | |
} |
#[derive(Copy, Clone, PartialEq, Eq, Debug)] | |
pub struct True; | |
#[derive(Copy, Clone, PartialEq, Eq, Debug)] | |
pub struct False; | |
pub trait Bool { | |
fn new() -> Self; | |
} | |
impl Bool for True { |
// The Babylonian Method | |
// http://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method | |
// @param n - the number to compute the square root of | |
// @param g - the best guess so far (can omit from initial call) | |
function squirt(n, g) { | |
if (!g) { | |
// Take an initial guess at the square root | |
g = n / 2.0; | |
} | |
var d = n / g; // Divide our guess into the number |
A zip function in javascript using .reduce
.
See Tom MacWright's post making juice with reduce
/ foldl
.
See also _.zip
and d3.zip
for alternative implementations and sample usage.
module.exports = function(redisClient,prefix) { | |
var Autocomplete = {}; | |
Autocomplete.prefix = prefix; | |
Autocomplete.terminal = "+"; | |
Autocomplete.add = function(word, next) { | |
function add(letters, key, last, x) { | |
var letter = last ? Autocomplete.terminal : letters[x]; | |
var score = last ? 0 : letter.charCodeAt(0); |