Skip to content

Instantly share code, notes, and snippets.

@reem
reem / all.js
Created November 25, 2015 23:06 — forked from anonymous/all.js
function all(promises) {
return promises.reduce(function (previous, next) {
return join(previous, next, function ([previous_results, next_val]) {
previous_results.push(next_val);
return previous_results;
});
}, Promise.resolve([]));
}
function join(x, y) {
fn main() {
#[deriving(Show)]
struct Foo {
a: i32
}
let mut test:Vec<Foo> = Vec::new();
test.push(Foo { a: 1 });
test.push(Foo { a: 3 });
test.push(Foo { a: 2 });
import numpy.random as nprnd
from time import clock
def r_step_generator(lo, hi):
num = lo
diff = hi - lo
while True:
num += nprnd.randint(0, diff)
if num < hi:
yield num