Module: Cohi
- Defined in:
- lib/cohi/version.rb,
lib/cohi.rb
Overview
Defined Under Namespace
Modules: VERSION
Classes: Function
Constant Summary
collapse
- FUNCS =
{}
- X =
Object.new
- XS =
Object.new
- X_XS =
Object.new
Instance Method Summary
collapse
Instance Method Details
#curry(f, *vs) ⇒ Object
76
77
78
|
# File 'lib/cohi.rb', line 76
def curry(f, *vs)
lambda {|v| f[*(vs + [v])] }
end
|
#define(sym, pat = nil, &f) ⇒ Object
68
69
70
71
72
73
74
|
# File 'lib/cohi.rb', line 68
def define(sym, pat = nil, &f)
FUNCS[sym] ||= Function.new(sym)
FUNCS[sym].add(pat, &f)
unless self.class.method_defined?(sym)
self.class.module_eval("def #{sym}; fun(:#{sym}); end")
end
end
|
#fun(sym) ⇒ Object
80
81
82
|
# File 'lib/cohi.rb', line 80
def fun(sym)
FUNCS[sym]
end
|