0.0
No release in over 3 years
Low commit activity in last 3 years
A collection of methods for creating series and iterators
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies
 Project Readme

Five Leaves

a collection of useful ruby methods

Examples

For more examples, see the unit tests

require 'five_leaves/lazy_enum'

def test_lazy_select_can_select_from_infinite_series
  assert_equal [0, 2, 4, 6, 8], (0..(1.0/0.0)).lazy_select { |x| x % 2 == 0 }.take(5)
end

def test_lazy_map_can_map_inifinite_series
  assert_equal [0, 2, 4, 6, 8], (0..(1.0/0.0)).lazy_map { |x| x * 2 }.take(5)
end

def test_series
  assert_equal [0, 2, 4, 6, 8], series { |x| x * 2 }.take(5)
  assert_equal [2, 4, 6, 8, 10], series(1) { |x| x * 2 }.take(5)
end

def test_lazy_zip_does
  zip = series { |x| x }.lazy_zip(series { |x| x+1 })
  assert_equal [0, 1], zip.next
  assert_equal [1, 2], zip.next
end

Naming

Five Leaves is named for a restaurant in Brooklyn, NY.

Copyright

Copyright (c) 2012 Matt Raibert. five_leaves is available under the GPL v3 see LICENSE.txt for further details.