Loops/Foreach: Difference between revisions

Content deleted Content added
PureFox (talk | contribs)
Added Wren
Line 325:
 
=={{header|BASIC}}==
 
==={{header|BaCon}}===
BaCon includes support for ''delimited strings''. Delimited strings form a type of collection. Along with with this support is a <code>for in</code> loop. Not quite a <code>for each</code> but pretty close.
 
<lang freebasic>OPTION COLLAPSE TRUE
FOR x$ IN "Hello cruel world"
PRINT x$
NEXT
 
FOR y$ IN "1,2,\"3,4\",5" STEP ","
PRINT y$
NEXT</lang>
 
{{out}}
<pre>prompt$ bacon -q forin.bac >/dev/null
prompt$ ./forin
Hello
cruel
world
1
2
"3,4"
5</pre>
 
The <code>OPTION COLLAPSE TRUE</code> statements prevents empty results when multiple delimiters appear together. The default delimiter is space, and can be changed with <code>OPTION DELIM x</code> where x is a static string literal.
 
==={{header|BASIC256}}===