Jump to content

Loops/Foreach: Difference between revisions

m
(Add Racket example)
Line 230:
<lang awk>for(i=1; i <= length(strs); i++) {
print strs[i]
}</lang>
 
Note that in awk, foreach loops can only be performed against an associative container. It is not possible to loop against an explicit list, so the following will not work:
 
<lang awk># This will not work
BEGIN {
for (l in "apples","bananas","cherries") {
print "I like " l
}</lang>
 
Cookies help us deliver our services. By using our services, you agree to our use of cookies.