Jump to content

Category:Wren-iterate

From Rosetta Code
Library
This is an example of a library. You may see a list of other libraries used on Rosetta Code at Category:Solutions by Library.

Wren-iterate is a module which enhances Wren's built-in iteration facilities by providing the wrapper classes: Stepped, Reversed and Indexed plus a helper class SeqEntry. The first two of these enable sequences to be iterated in either (or both) a stepped fashion (steps > 1) or in reverse. The third enables the iteration to include the zero-based index of the sequence elements and SeqEntry assists with this.

It also contains:

  • The Loop class which enables a parameterless function to be called repeatedly either for a fixed number of times or until some condition is met. The function is always called at least once.
  • The Pipe class which iterates through a list of functions or fibers passing the output of each element to the next element in the list and returning the final result.

It is the forty-first in a series of modules (listed on the language's main page) designed to assist with writing Rosetta Code tasks so the same code does not have to be written or copy/pasted time and time again thereby bloating a task's script code unnecessarily.

To use it all you need to do is to copy the source code (in the talk page) to a text file called iterate.wren and place this in the same directory as the importing script or module so the command line interpreter can find it.

Cookies help us deliver our services. By using our services, you agree to our use of cookies.