Tinderbox v10 Icon

Functional control structure operators

Functional control structure

These control structures are used with functional stream processing.

String.eachLine(x[:condition]){action}

The .eachLine(){} operator allows iteration through each line of a string, performing an action on each. For attributes like $Text, a line equates to a paragraph as the delimiter is a line break character.

String.try{action}[.thenTry{action}]

Saves the value of an attribute and attempts an action. If the action fails because one of its operators fails or the fail() operator is performed, the value of the attribute used as a stream source

A .try{} may be followed by one or more .thenTry{} clauses. If the original .try{} succeeded, all subsequent .thenTry{} clauses are ignored. If the original .try{} failed, then each .thenTry{} is attempted in turn. Once a .thenTry{} clause succeeds, subsequent .thenTry{} clauses are ignored.

String.failed()

tests for a failed stream processing action, e.g. using Stream.try{}. Its use include an explicit fail() call.