ruby 2.2.2p95 (2015-04-13 revision 50295) [x86_64-darwin14]
class A
end
a = A.new
A === a
export function prop<O: { +[string]: mixed }, P: $Keys<O>>( | |
p: P | |
): (o: O) => $ElementType<O, P> { | |
return function(o) { | |
return o[p]; | |
}; | |
} | |
const f = prop('hi'); |
node_modules/ |
const c = { | |
and: a => b => a(b)(c.false), | |
exp: m => n => n(m), | |
false: a => b => b, | |
isEQ: m => n => c.and(c.isLE(m)(n))(c.isLE(n)(m)), | |
isLE: m => n => c.isZ(c.sub(m)(n)), | |
isZ: n => n(x => c.false)(c.true), | |
mult: m => n => f => m(n(f)), | |
plus: m => n => f => x => m(f)(n(f)(x)), | |
pred: n => f => x => n(g => h => h(g(f)))(u => x)(u => u), |
N = 10_000_000 | |
class Foo | |
def initialize | |
@ary = (0..N).map { Object.new } | |
end | |
def a | |
# this is a closure that has captured self | |
define_singleton_method("O_o") {} |
N = 10_000_000 | |
class Foo | |
def initialize | |
@ary = (0..N).map { Object.new } | |
end | |
def a | |
return proc do | |
"hello" |
-- in haskell, this is all abstracted away by syntactic sugar. | |
-- although the function type syntax probably looks familiar. | |
add :: Integer -> Integer -> Integer | |
add x y = x + y | |
-- can curry as well | |
inc = add 1 | |
-- haskell functions all only have one arg in reality, | |
-- further arguments are always handled this way |
class Contract | |
@created = {} | |
@fullfilled = {} | |
def self.create argument | |
@created[argument] = caller[0] | |
end | |
def self.fulfill argument | |
@fullfilled[argument] = caller[0] |
type Result { | |
Value T | |
Err error | |
} |
asldkjaldkj |