Loop over multiple arrays simultaneously: Difference between revisions

Content added Content deleted
m (syntax highlighting fixup automation)
No edit summary
Line 297: Line 297:


If the arrays are not the same length, a subscript range error would occur when a non-existant element was accessed.
If the arrays are not the same length, a subscript range error would occur when a non-existant element was accessed.

=={{header|Amazing Hopper}}==
Versión 1: todos los arrays tienen el mismo tamaño:
<syntaxhighlight lang="txt">
#include <jambo.h>

Main
Void 'x,y,z'
Set '"a","b","c"' Append to list 'x'
Set '"A","B","C"' Append to list 'y'
Set '1,2,3' Append to list 'z'
i=1
Loop
[i++], Printnl ( Get 'x', Get 'y', Get 'z' )
Back if less-equal (i, 3)
End
</syntaxhighlight>
{{out}}
<pre>
aA1
bB2
cC3
</pre>
Versión 2: los arrays tienen distinto tamaño:
<syntaxhighlight lang="txt">
#include <jambo.h>

Main
Void 'x,y,z'
Set '"a","b","c"' Append to list 'x'
Set '"A","B","C","D","E"' Append to list 'y'
Set '1,2,3,4' Append to list 'z'
i=1, error=0
Loop
[i++],
Try ; Get 'x', Print it ; Catch 'error' ; Finish
Try ; Get 'y', Print it ; Catch 'error' ; Finish
Try ; Get 'z', Print it ; Catch 'error' ; Finish
Prnl
Back if less-equal (i, 5)
End
</syntaxhighlight>
{{out}}
<pre>
aA1
bB2
cC3
D4
E
</pre>


=={{header|APL}}==
=={{header|APL}}==