I hereby claim:
- I am dwickstrom on github.
- I am dwickstrom (https://keybase.io/dwickstrom) on keybase.
- I have a public key ASC9XLlpE9HjjPKrx6xLsiUrus-PsONoWrT4wmmJass3qwo
To claim this, I am signing this object:
| const isThenable = val => | |
| val | |
| && typeof val === 'object' | |
| && typeof val.then === 'function' | |
| const map = fn => arg => | |
| isThenable(arg) ? arg.then(fn) | |
| : Array.isArray(arg) ? arg.map(fn) | |
| : /* else */ ? fn(arg) |
| const foo = a => | |
| a === 1 ? 'one' | |
| : a === 2 ? 'two' | |
| : a === 3 ? 'three' | |
| : /* else */ 'more' | |
| const hello = foo => bar => | |
| foo < bar ? foo * 2 | |
| : foo > bar ? bar * 2 |
| from itertools import chain, imap | |
| def curry(fn): | |
| def curried(*args, **kwargs): | |
| if len(args) + len(kwargs) >= fn.__code__.co_argcount: | |
| return fn(*args, **kwargs) | |
| return (lambda *args2, **kwargs2: | |
| curried(*(args + args2), **dict(kwargs, **kwargs2))) | |
| return curried |
| Promise.of = Promise.resolve | |
| Promise.prototype.chain = Promise.prototype.then | |
| Promise.prototype.map = Promise.prototype.then | |
| Promise.prototype.ap = function (other) { | |
| this.chain(f => other.map(x => f(x))) | |
| } |
| // unit :: Applicative a => a -> b -> a b | |
| const of = t => x => t.of(x) | |
| of (Right) (1) |
| function * xrange (step, start, stop) { | |
| let i = start | |
| while (i < stop) { | |
| yield i | |
| i = i + step | |
| } | |
| } | |
| //+ zip :: [a] -> [b] -> [(a, b)] | |
| const zip = ([x, ...xs]) => ([y, ...ys]) => | |
| [[x, y], ...zip (xs) (ys)] | |
| const zip = xs => ys => | |
| xs.reduce((acc, curr, idx) => | |
| [[curr, ys[idx]], ...acc], []) |
| // take :: Int -> [a] -> [a] | |
| const take = n => ([x, ...xs]) => | |
| !x ? | |
| [] : | |
| n === 0 ? | |
| [] : | |
| [x, ...take (n-1) (xs)] |
| // fooIsBar :: Int -> String | |
| const fooIsBar = x => | |
| x == 1 ? 'one' | |
| : x == 2 ? 'two' | |
| : x == 3 ? 'three' | |
| : x == 4 ? 'four' | |
| : /* or */ 'too much' | |
I hereby claim:
To claim this, I am signing this object: