Method: Object#unfold
- Defined in:
- lib/rmtools/functional/unfold.rb
#unfold(breaker = lambda{|x|x.b}, &splitter) ⇒ Object
@ breaker must be callable that returns true value if that’s it @ &splitter must return a pair
6 7 8 9 10 11 12 13 |
# File 'lib/rmtools/functional/unfold.rb', line 6 def unfold(breaker=lambda{|x|x.b}, &splitter) obj, container = self, [] until breaker.call obj obj, next_element = splitter[obj] container.unshift next_element end container end |