Class: Remap::Iteration::Array

Inherits:
Concrete
  • Object
show all
Defined in:
lib/remap/iteration/array.rb

Instance Method Summary collapse

Instance Method Details

#map(&block) ⇒ Object Also known as: call



11
12
13
14
15
16
17
18
19
# File 'lib/remap/iteration/array.rb', line 11

def map(&block)
  value.each_with_index.reduce(init) do |input_state, (value, index)|
    block[value, index: index]._.then do |new_state|
      new_state.fmap { [_1] }
    end.then do |new_array_state|
      input_state.merged(new_array_state)
    end
  end._
end