H (Hybrid) Language - v0.03, by Dr. Herong Yang
"for" Loop Statement
This section describes what is a 'for' loop statement in H language.
A "for" loop statement is a statement that executes a sub-statement repeatedly for each element from a given array.
A "for" loop statement has the following syntax:
$for x $in array, sub-statement;
Examples of "for" loop statements are:
$for x $in array(1,2,3,4,5), write("x = "+x); list = range(1,100); sum = 0; $for x $in list, sum = sum + x; # the following loop prints the first 3 items # from a shopping list $for x $in array(0,1,2), ( item = shoppingList[x]; write("Item "+(x+1)+": "+item); );
Table of Contents