Iterators Sub-Module Documentation⚓︎
Overview⚓︎
The StringIterators Sub-Library provides a set of functions for iterating through various components of a string.
These functions return an iterator function that can be used to iterate through each character, word, sentence, or line in a string.
Functions⚓︎
ICharacters⚓︎
Purpose⚓︎
Returns an iterator function that returns each character in the string Str
one at a time.
Syntax⚓︎
ICharacters(Str: string): ((string, number) -> (number, string), string, number)
Parameters⚓︎
Str: string
The input string to iterate over its characters.
Returns⚓︎
- function
An iterator function that returns the next character in the string on each call. - number
The index of the character in the input string. - string
The character.
Examples⚓︎
1 2 3 4 |
|
1 2 3 4 5 6 |
|
IWords⚓︎
Purpose⚓︎
This function returns an iterator function that returns each word in the string Str
one at a time.
Words are defined as sequences of non-whitespace characters separated by one or more whitespace characters.
Syntax⚓︎
IWords(Str: string): ((string, number): ((string, number) -> (number, number, string), string, number)
Parameters⚓︎
Str: string
The input string to iterate over its words.
Returns⚓︎
- function
An iterator function that returns the next word in the string on each call. - number
The start index of the word in the input string. - number
The end index of the word in the input string. - string
The word itself.
Examples⚓︎
1 2 3 4 |
|
1 2 3 4 5 |
|
ISentences⚓︎
Purpose⚓︎
Returns an iterator function that returns each sentence in the input string one at a time.
Sentences are defined as sequences of characters separated by one or more sentence-ending punctuation characters (e.g. .
, ?
, !
).
Syntax⚓︎
ISentences(Str: string): ((string) -> (number, number, string, string), string, number)
Parameters⚓︎
Str: string
The input string to iterate over its words.
Returns⚓︎
- function
An iterator function that returns the next sentence in the string on each call. - number
The start index of the sentence in the input string. - number
The end index of the sentence in the input string. - string
The sentence. - string
The ending punctuation of the sentence (e.g..
,?
,!
).
Examples⚓︎
1 2 3 4 5 6 7 8 |
|
1 2 3 |
|