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
42 def pre(f, preds): | |
43 | |
44 @wraps(f) | |
45 def inner(*args, **kwargs): | |
46 for pred in preds: | |
47 assert pred(*args, **kwargs) | |
48 return f(*args, **kwargs) | |
49 | |
50 return inner | |
51 |
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
from functools import wraps | |
from datetime import datetime | |
def memo(f): | |
cache = {} | |
@wraps(f) | |
def inner(*args, **kwargs): | |
key = str(args) + str(kwargs) |
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
data BExp = TRUE | |
| FALSE | |
| AND BExp BExp | |
| OR BExp BExp | |
| NOT BExp | |
| QUANT QExp | |
beval :: BExp -> Bool | |
beval TRUE = True |
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
asyncMap = function(fn, list, callback){ | |
var counter = 0; | |
var result = list.slice(); | |
list.forEach(function(elem, index){ | |
setTimeout(function(){ | |
if(++counter === result.length){ | |
callback(result); | |
} | |
result[index] = fn(elem); | |
}, |
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 <stdio.h> | |
int main(int argc, char *argv[]){ | |
int x = 1; | |
x += x++ + ++x; | |
printf("%i", x); | |
} |
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
// +build darwin | |
package plugins | |
import ( | |
"os/exec" | |
"log" | |
"strconv" | |
) | |
type Cpu struct { |
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
from random import random | |
envs = [1, 2] | |
swapping = 0 | |
staying = 0 | |
for x in xrange(100000000): | |
if random() <= .5: | |
envs.reverse() |
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
from random import random | |
from math import pi, fabs | |
accuracies = { | |
'10': 0, | |
'100': 0, | |
'1000': 0, | |
'10000': 0, | |
'100000': 0, |
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
from random import random | |
value = 0 | |
acc = 0 | |
payout = 2 | |
for n in xrange(1, 1000001): | |
for x in xrange(10000000): | |
if random() <= .5: |
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
from functools import wraps | |
from datetime import datetime | |
def time(f): | |
@wraps(f) | |
def inner(*args, **kwargs): | |
start = datetime.now() | |
res = f(*args, **kwargs) | |
delta = datetime.now() - start |
OlderNewer