Loop over multiple arrays simultaneously: Difference between revisions
Content deleted Content added
→{{header|D}}: add implementation |
added PowerBASIC (and rephrased task description a bit) |
||
Line 1:
{{task|Iteration}}Loop over multiple arrays (or lists or tuples
<pre>aA1
bB2
Line 140:
print_newline()
) a1 ;;</lang>
=={{header|PowerBASIC}}==
<lang powerbasic>FUNCTION PBMAIN () AS LONG
DIM x(2), y(2) AS STRING * 1
DIM z(2) AS LONG
'data
ARRAY ASSIGN x() = ("a", "b", "c")
ARRAY ASSIGN y() = ("A", "B", "C")
ARRAY ASSIGN z() = (1, 2, 3)
'set upper bound
C& = UBOUND(x)
IF UBOUND(y) > C& THEN C& = UBOUND(y)
IF UBOUND(z) > C& THEN C& = UBOUND(z)
OPEN "output.txt" FOR OUTPUT AS 1
FOR L& = 0 TO C&
IF L& <= UBOUND(x) THEN PRINT #1, x(L&);
IF L& <= UBOUND(y) THEN PRINT #1, y(L&);
IF L& <= UBOUND(z) THEN PRINT #1, TRIM$(STR$(z(L&)));
PRINT #1,
NEXT
CLOSE
END FUNCTION
</lang>
=={{header|Python}}==
|