What are the Ruby equivalent of Python itertools, esp. combinations/permutations/groupby?

Posted by Amadeus on Stack Overflow See other posts from Stack Overflow or by Amadeus
Published on 2010-03-14T18:32:47Z Indexed on 2010/03/14 18:55 UTC
Read the original article Hit count: 311

Python's itertools module provides a lots of goodies with respect to processing an iterable/iterator by use of generators. For example,

permutations(range(3)) --> 012 021 102 120 201 210

combinations('ABCD', 2) --> AB AC AD BC BD CD

[list(g) for k, g in groupby('AAAABBBCCD')] --> AAAA BBB CC D

What are the equivalent in Ruby?

By equivalent, I mean fast and memory efficient (Python's itertools module is written in C).

© Stack Overflow or respective owner

Related posts about ruby

Related posts about itertools