Category:Wren-iterate: Difference between revisions

From Rosetta Code
Content added Content deleted
(Change to blurb following addition of Pipe class.)
m (Now using internal links to related pages)
 
Line 8: Line 8:
* 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.
* 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 [https://rosettacode.org/wiki/Category:Wren 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.
It is the forty-first in a series of modules (listed on the language's [[:Category:Wren|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 [https://rosettacode.org/wiki/Category_talk:Wren-iterate 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.
To use it all you need to do is to copy the source code (in the [[:Category_talk:Wren-iterate|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.

Latest revision as of 16:07, 9 May 2023

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.