class Flor::Pro::Reduce

Protected Instance Methods

determine_iteration_args() click to toggle source
# File lib/flor/pcore/reduce.rb, line 79
def determine_iteration_args

  super.unshift([ 'res', @node['res'] ])
end
iterator_result() click to toggle source
# File lib/flor/pcore/reduce.rb, line 89
def iterator_result

  @node['res']
end
prepare_iterations() click to toggle source
# File lib/flor/pcore/reduce.rb, line 50
def prepare_iterations

  @node['args']
    .each { |a|
      if Flor.is_func_tree?(a)
        @node['fun'] ||= a
      elsif Flor.is_proc_tree?(a)
        @node['fun'] ||= proc_to_fun(a)
      elsif Flor.is_collection?(a)
        @node['ocol'] ||= a
      else
        @node['res'] ||= a
      end }

  @node['ocol'] ||= node_payload_ret
  ocol = @node['ocol']

  fail Flor::FlorError.new(
    "function not given to #{heap.inspect}", self
  ) unless @node['fun']
  fail Flor::FlorError.new(
    "collection not given to #{heap.inspect}", self
  ) unless Flor.is_collection?(ocol)

  @node['col'] = Flor.to_coll(@node['ocol'])
  @node['res'] ||= @node['col'].shift
  @node['args'] = nil
end
proc_to_fun(prc) click to toggle source
# File lib/flor/pcore/reduce.rb, line 94
def proc_to_fun(prc)

  h = prc[1]['proc']
  l = tree[2]

  [ '_func',
    { 'nid' => "#{nid}_0_1",
      'tree' =>
        [ 'def', [
          [  '_att', [ [ 'r', [], l ] ], l ],
          [  '_att', [ [ 'x', [], l ] ], l ],
          [  h, [ [ 'r', [], l ], [ 'x', [], l ] ], l ]
        ], l ],
      'cnid' => '0',  #
      'fun' => 0 },   # TODO really?
    l ]
end
receive_iteration() click to toggle source
# File lib/flor/pcore/reduce.rb, line 84
def receive_iteration

  @node['res'] = payload['ret']
end