Icon+Unicon/Intro: Difference between revisions

(→‎An Ugly Example: elaboration)
Line 668:
 
The additional alternations are required to prevent the expression from running out of results. Part of this is due to the use of ''return'' and ''break'' to exit the loop preventing further results being generated.
 
The loop can be abstracted so:
<lang Icon>every (|A()) | B() | C()</lang>
 
Without the &null alternations (or the not expressions), once the repeated alternation fails there are no more results left to generate or backtrack into and the expression must move on. In the example, neither A() nor B() would not produce any results as they exit if successful. Since C() produces only one result and that ends the evaluation.
 
Overall, this example is not a very good use of these techniques.
Anonymous user