Class: Proc

Inherits:
Object
  • Object
show all
Defined in:
lib/functions/prelude_lambda/ext.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.compose(f, g) ⇒ Object



13
14
15
# File 'lib/functions/prelude_lambda/ext.rb', line 13

def self.compose(f, g)
  ->(*args) { g[f[*args]] }
end

Instance Method Details

#+(g) ⇒ Object

Composition of Procs (functions): (f+g)(x) = f(g(x))



17
18
19
20
# File 'lib/functions/prelude_lambda/ext.rb', line 17

def +(g)
  # Prelude::Compose.(self,g)
  ->(*x) { self.(g.(*x)) }
end

#<(g) ⇒ Object

Composition of Procs (functions): (f<g)(x) = f(g(x))



22
23
24
25
# File 'lib/functions/prelude_lambda/ext.rb', line 22

def <(g)
  # Prelude::Compose.(self,g)
  ->(*x) { self.(g.(*x)) }
end

#>(g) ⇒ Object

Composition of Procs (functions): (f>g)(x) = g(f(x))



27
28
29
30
# File 'lib/functions/prelude_lambda/ext.rb', line 27

def >(g)
  # Prelude::After.(self,g)
  ->(*x) { g.(self.(*x)) }
end

#partial(a) ⇒ Object

Partial evaluation of a Proc (function)



32
33
34
# File 'lib/functions/prelude_lambda/ext.rb', line 32

def partial(a)
  self.curry.(a)
end