module Lab42::Function::Constructors

Constants

R

Public Instance Methods

a(n)
Alias for: placeholder
a1() click to toggle source
# File lib/lab42/function/constructors.rb, line 47
def a1; placeholder 1 end
a2() click to toggle source
# File lib/lab42/function/constructors.rb, line 48
def a2; placeholder 2 end
a3() click to toggle source
# File lib/lab42/function/constructors.rb, line 49
def a3; placeholder 3 end
c(const_val)
Alias for: constant
constant(const_val) click to toggle source
# File lib/lab42/function/constructors.rb, line 8
def constant const_val
  new ->{ const_val }, 0
end
Also aliased as: c
f()
Alias for: force_pipe
force_pipe() click to toggle source
# File lib/lab42/function/constructors.rb, line 26
def force_pipe
  @__force_pipe__ ||= BasicObject.new
end
Also aliased as: f
free_receiver(msg, *first_stage_params, &blk) click to toggle source
# File lib/lab42/function/constructors.rb, line 13
def free_receiver msg, *first_stage_params, &blk
  unless blk
    return new ->(rcv, *second_stage_params){
      mthd = rcv.method(msg)
      mthd.(*R.combine_and_reorder(first_stage_params, second_stage_params))
    }
  end

  chained_free_receiver msg, first_stage_params, blk
end
Also aliased as: s
p(rcv, msg, *first_stage_params, &blk)
Alias for: partial
partial(rcv, msg, *first_stage_params, &blk) click to toggle source
# File lib/lab42/function/constructors.rb, line 31
def partial rcv, msg, *first_stage_params, &blk
  mthd = rcv.method msg
  unless blk
    return new ->(*second_stage_params){
      mthd.(*R.combine_and_reorder(first_stage_params, second_stage_params))
    }
  end

  chained_partial mthd, first_stage_params, blk
end
Also aliased as: p
placeholder(n) click to toggle source
# File lib/lab42/function/constructors.rb, line 43
def placeholder n
  Function::Placeholder.make(n)
end
Also aliased as: a
s(msg, *first_stage_params, &blk)

The free_receiver's abbreviation s stands for `send`

Alias for: free_receiver

Private Instance Methods

chained_free_receiver(msg, first_stage_params, blk) click to toggle source
# File lib/lab42/function/constructors.rb, line 53
def chained_free_receiver msg, first_stage_params, blk
  new ->(rcv, *second_stage_params){
    mthd = rcv.method msg
    beh_params, blk_params = split_by_arity(mthd, second_stage_params)
    blk_params ||= []
      raise ArgumentError unless blk.arity == blk_params.size + 1 || blk.arity < 0
    blk.(mthd.(*R.combine_and_reorder(first_stage_params, beh_params)), *blk_params)
  }
end
chained_partial(mthd, first_stage_params, blk) click to toggle source
# File lib/lab42/function/constructors.rb, line 63
def chained_partial mthd, first_stage_params, blk
  new ->(*second_stage_params){
    beh_params, blk_params = split_by_arity(mthd, second_stage_params)
    blk_params ||= []
    raise ArgumentError unless blk.arity == blk_params.size + 1 || blk.arity < 0
    blk.(mthd.(*R.combine_and_reorder(first_stage_params, beh_params)), *blk_params)
  }
end
split_by_arity(mthd, params) click to toggle source
# File lib/lab42/function/constructors.rb, line 72
def split_by_arity mthd, params
  return [params, []] if mthd.arity < 0

  a = mthd.arity
  [params[0...a], params[a..-1]]
end