Module: Necromancy::Control::Category

Extended by:
Necromancy::Control
Included in:
Arrow
Defined in:
lib/necromancy/control/category.rb

Instance Method Summary collapse

Methods included from Necromancy::Control

[], call, extended, hiding, new, using

Instance Method Details

#<(callable) ⇒ Necromancy

Note:
self

b -> c

Right-to-left composition

Examples:

require 'necromancy'
N = Necromancy.Category.new
f = lambda(&N.to_i < N * 2) # == ->(o) { (o * 2).to_i }
f.('42') # => 4242

Parameters:

  • callable (Object)

    a -> b

Returns:



32
33
34
35
36
# File 'lib/necromancy/control/category.rb', line 32

def <(callable)
  str = make_evaluable_string(callable)
  necromancy = "args = (#{str}); #{@necromancy}"
  self.class.new(necromancy, @references.dup)
end

#>(callable) ⇒ Necromancy

Note:
self

a -> b

Left-to-right composition.

Examples:

require 'necromancy'
N = Necromancy.Category.new
f = lambda(&N.to_i > N * 2) # == ->(o) { o.to_i * 2 }
f.('42') # => 84

Parameters:

  • callable (Object)

    b -> c

Returns:



17
18
19
20
21
# File 'lib/necromancy/control/category.rb', line 17

def >(callable)
  str = make_evaluable_string(callable)
  necromancy = "args = (#{@necromancy}); #{str}"
  self.class.new(necromancy, @references.dup)
end