module Necromancy::Control::Applicative
Public Instance Methods
*(callable)
click to toggle source
- @note self
-
a -> b -> c
@param [Object] callable a -> b @return [Necromancy] a -> c @example
require 'necromancy' N = Necromancy.Applicative.new f = lambda(&N.+ * N) # == ->(o) {o + o} f.(42) # => 84
# File lib/necromancy/control/applicative.rb, line 16 def *(callable) str = make_evaluable_string(callable) self.class.new("args.concat((#{str})); #{@necromancy}", @references.dup) end
Also aliased as: __Applicative_Astarisk
**(callable)
click to toggle source
A variant of {#*} with the arguments reversed.
- @note self
-
a -> b
@param [Object] callable a -> b -> c @return [Necromancy] a -> c @example
require 'necromancy' N = Necromancy.Applicative.new f = lambda(&N ** :+) # == ->(o) {o + o} f.(42) # => 84
# File lib/necromancy/control/applicative.rb, line 30 def **(callable) str = make_evaluable_string(callable) self.class.new(str, @references.dup).__Applicative_Astarisk(self) end
<<(callable)
click to toggle source
Sequence actions, discarding the value of the callable.
- @note self
-
a -> b
@param [Object] callable a -> _ @return [Necromancy] a -> b @example
require 'necromancy' N = Necromancy.Applicative.new f = lambda(&N.succ << N.pred) # == ->(o) {o.pred; o.succ} f.(42) # => 43
# File lib/necromancy/control/applicative.rb, line 44 def <<(callable) self.class.new("args.pop; #{@necromancy}", @references.dup).__Applicative_Astarisk(callable) end
>>(callable)
click to toggle source
Sequence actions, discarding the value of self.
- @note self
-
a -> _
@param [Object] callable a -> b @return [Necromancy] a -> b @example
require 'necromancy' N = Necromancy.Applicative.new f = lambda(&N.succ >> N.pred) # == ->(o) {o.succ; o.pred} f.(42) # => 41
# File lib/necromancy/control/applicative.rb, line 57 def >>(callable) str = make_evaluable_string(callable) self.class.new("args.pop; #{str}", @references.dup).__Applicative_Astarisk(self) end