-=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- (c) WidthPadding Industries 1987 0|554|0 -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=-
SoCoder -> Snippet Home -> Misc


 
Cower
Created : 24 July 2009
Edited : 25 July 2009
Language : Blitz Max

Generic Enumerator

Generic enumerator that will let you enumerate over anything, including enumerators

This is inspired by Warpy's code here: www.blitzbasic.com/codearcs/codearcs.php?code=2496

It's sort of the same idea, except that you can iterate over strings, and it should ideally support multidimensional arrays, strings (iterates over each character of the string), and it should be faster when iterating over the contents of TLists, TMaps, etc. since it's not going through the reflection module when calling the methods for their own enumerators.

This was mainly written so I could have an Inject method along the same lines as Ruby's Enumerable#inject. Works pretty well, I think, so I figured I'd share this bit of code, at least.

This code is Public Domain.


 

Comments