Problem The task is to enhance the Enumerable module with a method nth(). The method shall create a new list, […]
Tag: iterator
Saving and resuming position while iterating over a container
Problem Background: I’m in the process of writing a relatively simple behavior tree driven AI system for a game that […]
LISP-like list class
Problem So, here’s my code: public class NList : SExp, IEnumerable<Object> { private Object _car; private NList _cdr; IEnumerator<Object> IEnumerable<Object>.GetEnumerator() […]
Lower level exception handling during enumeration
Problem I’ve got pretty straight forward scenario. I’ve got a class called FileInformationExtractor and method GetFilesInformation that takes directory path […]
A deduplicating iterator
Problem Implement an iterator (generic) which skips an element if it is equal to the previous element. e.g: AAABBCCCCD, produces […]
A Java Iterable over multiple arrays
Problem GlueArrays is used for iterating over an array of arrays, and it looks like this: Main.java import java.util.Iterator; import […]
Graceful way to iterate through two arrays and build a master array?
Problem params[:controller_id].each do |cid| params[:zone_number].each do |pzn| zone_ids << Zone.find_by_controller_id_and_number(cid,pzn).id end end I have multiple controllers and multiples zone_numbers, and […]
Radio with channels
Problem Realize the Radio and Channel classes that represent radio and a radio station. The radio class offers an argumentless […]
Cyclic generator with access to current local state and executes callback after each cycle
Problem I’m working on a Python class that is a cyclic generator, like itertools.cycle, but it offers access to its […]
Stream “on the fly” from matrix
Problem I want to produce a Stream<Pixel> from a Pixel[][]. My code for this is extremely verbose so I suspect […]