22 Commits

Author SHA1 Message Date
Yukihiro "Matz" Matsumoto f3cd991771 mruby-enum-lazy: add Enumerator::Lazy#tap_each
add tap_each method that yields each element for side effects
(e.g. logging, debugging) and passes it through unmodified.
see https://bugs.ruby-lang.org/issues/21520

Co-authored-by: Claude <noreply@anthropic.com>
2026-04-23 19:25:25 +09:00
Chris Hasiński 8f71887e46 Improve flat_map test descriptions for clarity 2026-03-28 23:14:46 +01:00
Chris Hasiński 3f52ef6cfc Fix Lazy#flat_map to handle non-enumerable block return values
When the block passed to Lazy#flat_map returns a non-enumerable value
(e.g. an Integer), mruby raised NoMethodError because it unconditionally
called #each on the result. CRuby yields non-enumerable values directly.

Use respond_to?(:each) to match CRuby behavior: iterate enumerable
results, yield non-enumerable results as-is.
2026-03-28 22:59:11 +01:00
Yukihiro "Matz" Matsumoto 0d4695a91c mruby-enum-lazy: standardize block parameter spacing
changed block spacing from method{ to method { for consistency.

Co-authored-by: Claude <noreply@anthropic.com>
2025-12-11 18:09:09 +09:00
Yukihiro "Matz" Matsumoto 0994d5be94 mruby-enum-lazy: add comprehensive call-seq documentation for lazy enumeration
Added complete call-seq documentation for all lazy enumeration methods in
mrblib/lazy.rb (16 methods):

## Enumerable Extension Methods:

- lazy: creates Enumerator::Lazy for deferred evaluation, enables efficient
  processing of infinite sequences and large datasets with comprehensive
  pythagorean triples example demonstrating real-world usage

## Enumerator::Lazy Class Methods:

- new: constructor for creating lazy enumerators with custom yielding logic,
  provides foundation for building custom lazy operations

- to_enum/enum_for: creates lazy enumerator from method calls, maintains
  lazy evaluation chain for custom enumerable methods

## Enumerator::Lazy Instance Methods:

- map/collect: lazy transformation of elements with deferred execution
- select/find_all: lazy filtering with conditional element inclusion
- reject: lazy filtering with conditional element exclusion
- grep: lazy pattern matching using case equality operator
- grep_v: lazy inverse pattern matching for exclusion filtering

- drop: lazy skipping of first n elements without immediate evaluation
- drop_while: lazy conditional skipping until predicate fails
- take: lazy limiting to first n elements with automatic termination
- take_while: lazy conditional taking until predicate fails

- flat_map/collect_concat: lazy flattening and mapping in single operation
- zip: lazy combining of multiple enumerables into tuples
- uniq: lazy uniqueness filtering with optional transformation block

- force: immediate evaluation alias for to_a, converts lazy chain to array

Co-authored-by: Atlassian Rovo Dev
2025-08-14 10:52:46 +09:00
Yukihiro "Matz" Matsumoto 8ef1d1e104 mruby-enum-lazy: add README.md
The document is written by Google Jules.
2025-06-13 04:45:48 +09:00
buty4649 031476a853 mruby-enum-lazy: add grep_v method 2024-02-15 14:55:38 +09:00
Yukihiro "Matz" Matsumoto 735fa246bf mruby-enumerator: remove internal attribute methods; ref #6068
Removed methods: obj, args, kwd, meth, fib.
2023-10-09 22:39:43 +09:00
Yukihiro "Matz" Matsumoto 4d249c28d9 Skip tests that use Float inside; ref #5421 2021-04-24 12:04:08 +09:00
Yukihiro "Matz" Matsumoto 0a0cc5a217 Check method existence for Enumerators; fix #3920
The issue #3920 was fixed but the fundamental flaw of lack of stack
depth check along with fibers still remains, even though it's not
easy to cause the issue.  Use `MRB_GC_FIXED_ARENA` to avoid the issue
for workaround.

After this patch, `obj.to_enum` raises `ArgumentError` if the object
does not respond to the enumerating method. This is incompatible to
CRuby but I think this behavior is better and CRuby should be updated
to behave like this.
2018-11-19 10:57:07 +09:00
Okumura Takahiro 0664c452ee Fix tinytypo 2018-03-16 00:19:09 +09:00
Yukihiro "Matz" Matsumoto db8265f428 Add Comparable#uniq; CRuby2.4 2017-10-17 12:46:51 +09:00
Yukihiro "Matz" Matsumoto 68470bef86 Check method existence in `to_enum'; ref #3773 2017-08-11 09:21:09 +09:00
Yukihiro "Matz" Matsumoto 057be5ffb5 use unless instead of if not. 2017-06-21 11:13:33 +09:00
Yukihiro "Matz" Matsumoto 779c2629fe resolve conflict; ref #3306 2016-11-30 12:54:20 +09:00
ksss 0f90227907 Change Lazy class outer
Lazy class should be under Enumerator instead of Enumerable
2016-11-30 12:36:22 +09:00
ksss 8675975ba2 Implement Enumerable::Lazy#to_enum and enum_for 2016-11-30 11:02:02 +09:00
Seba Gamboa 25c8e95365 Revert "Mark core gems with mrbgem tag"
This reverts commit 5cdcce8dbd.
2015-10-21 14:31:13 -03:00
Seba Gamboa 5cdcce8dbd Mark core gems with mrbgem tag 2015-10-20 12:16:47 -03:00
Yukihiro "Matz" Matsumoto 5867167ffd add dependency information based on #2239; fix #2236, close #2239 2014-05-13 13:08:18 +09:00
Nobuyoshi Nakada ab67c57f65 remove trailing spaces 2014-04-30 09:50:14 +09:00
Yukihiro "Matz" Matsumoto 7a9630a5bb add mruby-enum-lazy mrbgem for Enumerable::Lazy 2014-04-04 10:33:17 +09:00