Another update from ingydotnet^djgoku

This commit is contained in:
Ingy döt Net 2015-11-18 06:14:39 +00:00
parent 91df62d461
commit 948b86eafa
7604 changed files with 108452 additions and 22726 deletions

View file

@ -1,7 +1,11 @@
Loop over multiple arrays (or lists or tuples or whatever they're called in your language) and print the ''i''th element of each.
Use your language's "for each" loop if it has one, otherwise iterate through the collection in order with some other loop.
Loop over multiple arrays (or lists or tuples or whatever they're called in
your language) and print the ''i''th element of each.
Use your language's "for each" loop if it has one, otherwise iterate
through the collection in order with some other loop.
For this example, loop over the arrays <code>(a,b,c)</code>, <code>(A,B,C)</code> and <code>(1,2,3)</code> to produce the output
For this example, loop over the arrays <code>(a,b,c)</code>,
<code>(A,B,C)</code> and <code>(1,2,3)</code>
to produce the output
<pre>aA1
bB2
cC3</pre>

View file

@ -1,4 +1,5 @@
[]UNION(CHAR,INT) x=("a","b","c"), y=("A","B","C"), z=(1,2,3);
[]UNION(CHAR,INT) x=("a","b","c"), y=("A","B","C"),
z=(1,2,3);
FOR i TO UPB x DO
printf(($ggd$, x[i], y[i], z[i], $l$))
OD

View file

@ -0,0 +1,11 @@
begin
% declare the three arrays %
string(1) array a, b ( 1 :: 3 );
integer array c ( 1 :: 3 );
% initialise the arrays - have to do this element by element in Algol W %
a(1) := "a"; a(2) := "b"; a(3) := "c";
b(1) := "A"; b(2) := "B"; b(3) := "C";
c(1) := 1; c(2) := 2; c(3) := 3;
% loop over the arrays %
for i := 1 until 3 do write( i_w := 1, s_w := 0, a(i), b(i), c(i) );
end.

View file

@ -7,6 +7,7 @@ procedure Array_Loop_Test is
A3 : array (Array_Index) of Integer := (1, 2, 3);
begin
for Index in Array_Index'Range loop
Put_Line (A1 (Index) & A2 (Index) & Integer'Image (A3 (Index))(2));
Put_Line (A1 (Index) & A2 (Index) & Integer'Image (A3
(Index))(2));
end loop;
end Array_Loop_Test;

View file

@ -10,8 +10,12 @@ MsgBox, % LoopMultiArrays()
;---------------------------------------------------------------------------
LoopMultiArrays() { ; print the ith element of each
LoopMultiArrays()
{ ; print the ith element of each
;---------------------------------------------------------------------------
local Result
StringSplit, List1_, List1, `,
StringSplit, List2_, List2, `,

View file

@ -1,4 +1,5 @@
main: { (('a' 'b' 'c')('A' 'B' 'C')('1' '2' '3')) simul_array }
main: { (('a' 'b' 'c')('A' 'B' 'C')('1' '2' '3'))
simul_array }
simul_array!:
{ trans

View file

@ -1,4 +1,5 @@
main: { (('a' 'b' 'c')('A' 'B' 'C')('1' '2' '3')) simul_array }
main: { (('a' 'b' 'c')('A' 'B' 'C')('1' '2' '3'))
simul_array }
simul_array!:
{{ dup

View file

@ -0,0 +1,5 @@
0 >:2g,:3g,:4gv
@_^#`2:+1,+55,<
abc
ABC
123

View file

@ -10,7 +10,8 @@ int main(int argc, char* argv[])
std::vector<char>::const_iterator lIt = ls.begin();
std::vector<char>::const_iterator uIt = us.begin();
std::vector<int>::const_iterator nIt = ns.begin();
for(; lIt != ls.end() && uIt != us.end() && nIt != ns.end();
for(; lIt != ls.end() && uIt != us.end() && nIt !=
ns.end();
++lIt, ++uIt, ++nIt)
{
std::cout << *lIt << *uIt << *nIt << "\n";

View file

@ -7,9 +7,11 @@ int main(int argc, char* argv[])
int ns[] = {1, 2, 3};
for(size_t li = 0, ui = 0, ni = 0;
li < sizeof(ls) && ui < sizeof(us) && ni < sizeof(ns) / sizeof(int);
li < sizeof(ls) && ui < sizeof(us) && ni
< sizeof(ns) / sizeof(int);
++li, ++ui, ++ni)
{
std::cout << ls[li] << us[ui] << ns[ni] << "\n";
std::cout << ls[li] << us[ui] << ns[ni] <<
"\n";
}
}

View file

@ -1,4 +1,5 @@
@public
run = fn () {
lists.foreach(fn ((A, B, C)) { io.format("~s~n", [[A, B, C]]) }, lists.zip3("abc", "ABC", "123"))
lists.foreach(fn ((A, B, C)) { io.format("~s~n", [[A, B, C]]) },
lists.zip3("abc", "ABC", "123"))
}

View file

@ -1,5 +1,6 @@
open console list imperative
xs = zipWith3 (\x y z -> show x ++ show y ++ show z) ['a','b','c'] ['A','B','C'] [1,2,3]
xs = zipWith3 (\x y z -> show x ++ show y ++ show z) ['a','b','c']
['A','B','C'] [1,2,3]
each writen xs

View file

@ -1 +1,2 @@
xs = zipWith3 (\x -> (x++) >> (++)) "abc" "ABC" "123"
xs = zipWith3 (\x -> (x++) >> (++)) "abc" "ABC"
"123"

View file

@ -0,0 +1,5 @@
l1 = ["a", "b", "c"]
l2 = ["A", "B", "C"]
l3 = ["1", "2", "3"]
IO.inspect List.zip([l1,l2,l3]) |> Enum.map(fn x-> Tuple.to_list(x) |> Enum.join end)
#=> ["aA1", "bB2", "cC3"]

View file

@ -0,0 +1,5 @@
l1 = 'abc'
l2 = 'ABC'
l3 = '123'
IO.inspect List.zip([l1,l2,l3]) |> Enum.map(fn x-> Tuple.to_list(x) end)
#=> ['aA1', 'bB2', 'cC3']

View file

@ -0,0 +1,4 @@
iex(1)> List.zip(['abc','ABCD','12345']) |> Enum.map(&Tuple.to_list(&1))
['aA1', 'bB2', 'cC3']
iex(2)> List.zip(['abcde','ABC','12']) |> Enum.map(&Tuple.to_list(&1))
['aA1', 'bB2']

View file

@ -1 +1,2 @@
lists:zipwith3(fun(A,B,C)-> io:format("~s~n",[[A,B,C]]) end, "abc", "ABC", "123").
lists:zipwith3(fun(A,B,C)->
io:format("~s~n",[[A,B,C]]) end, "abc", "ABC", "123").

View file

@ -1,2 +1,3 @@
lists:foreach(fun({A,B,C}) -> io:format("~s~n",[[A,B,C]]) end,
lists:foreach(fun({A,B,C}) ->
io:format("~s~n",[[A,B,C]]) end,
lists:zip3("abc", "ABC", "123")).

View file

@ -1 +1,2 @@
"abc" "ABC" "123" [ [ write1 ] tri@ nl ] 3each
"abc" "ABC" "123" [ [ write1 ] tri@ nl ]
3each

View file

@ -1,6 +1,9 @@
# The Loop function will apply some function to every tuple built by taking
# the i-th element of each list. If one of them is exhausted before the others,
# the loop continues at its begining. Only the longests lists will be precessed only once.
# The Loop function will apply some function to every tuple built by
taking
# the i-th element of each list. If one of them is exhausted before the
others,
# the loop continues at its begining. Only the longests lists will be
precessed only once.
Loop := function(a, f)
local i, j, m, n, v;
n := Length(a);

View file

@ -0,0 +1,2 @@
{-# LANGUAGE ParallelListComp #-}
main = sequence [ putStrLn [x, y, z] | x <- "abd" | y <- "ABC" | z <- "123"]

View file

@ -0,0 +1,2 @@
import Data.List
main = mapM putStrLn $ transpose ["abd", "ABC", "123"]

View file

@ -0,0 +1,2 @@
import Data.List
main = mapM putStrLn $ zipWith3 (\a b c -> [a,b,c]) "abc" "ABC" "123"

View file

@ -0,0 +1,2 @@
import Control.Applicative
main = sequence $ getZipList $ (\x y z -> putStrLn [x, y, z]) <$> ZipList "abd" <*> ZipList "ABC" <*> ZipList "123"

View file

@ -1 +0,0 @@
main = mapM_ putStrLn $ zipWith3 (\a b c -> [a,b,c]) "abc" "ABC" "123"

View file

@ -0,0 +1,14 @@
var lstOut = ['', '', ''];
[["a", "b", "c"], ["A", "B", "C"], ["1", "2", "3"]].forEach(
function (a) {
[0, 1, 2].forEach(
function (i) {
// side-effect on an array outside the function
lstOut[i] += a[i];
}
);
}
);
// lstOut --> ["aA1", "bB2", "cC3"]

View file

@ -0,0 +1,17 @@
(function (lstArrays) {
return lstArrays.reduce(
function (a, e) {
return [
a[0] + e[0],
a[1] + e[1],
a[2] + e[2]
];
}, ['', '', ''] // initial copy of the accumulator
).join('\n');
})([
["a", "b", "c"],
["A", "B", "C"],
["1", "2", "3"]
]);

View file

@ -0,0 +1,16 @@
(function (x, y, z) {
// function of arity 3 mapped over nth items of each of 3 lists
// (a -> b -> c -> d) -> [a] -> [b] -> [c] -> [d]
function zipWith3(f, xs, ys, zs) {
return zs.length ? [f(xs[0], ys[0], zs[0])].concat(
zipWith3(f, xs.slice(1), ys.slice(1), zs.slice(1))) : [];
}
function concat(x, y, z) {
return ''.concat(x, y, z);
}
return zipWith3(concat, x, y, z).join('\n')
})(["a", "b", "c"], ["A", "B", "C"], [1, 2, 3]);

View file

@ -0,0 +1,24 @@
(function (lists) {
// [[a]] -> [[a]]
function zip(lists) {
var lng = lists.length,
lstHead = lng ? [].concat.apply([], lists.map(function (lst) {
return lst.length ? [lst[0]] : [];
})) : [];
return lstHead.length === lng ? [lstHead].concat(
zip(lists.map(function (x) {
return x.slice(1);
}))
) : [];
}
// [a] -> s
function concat(lst) {
return ''.concat.apply('', lst);
}
return zip(lists).map(concat).join('\n')
})([["a", "b", "c"], ["A", "B", "C"], [1, 2, 3]]);

View file

@ -1,4 +1,5 @@
julia> map(println, ('a','b','c'),('A','B','C'),(1,2,3)) ;
julia> map(println,
('a','b','c'),('A','B','C'),(1,2,3)) ;
aA1
bB2
cC3

View file

@ -1,4 +1,5 @@
julia> for (i,j,k) in zip(('a','b','c'),('A','B','C'),(1,2,3))
julia> for (i,j,k) in
zip(('a','b','c'),('A','B','C'),(1,2,3))
println(i,j,k)
end
aA1

View file

@ -1,3 +1,5 @@
show (map [(word ?1 ?2 ?3)] [a b c] [A B C] [1 2 3]) ; [aA1 bB2 cC3]
show (map [(word ?1 ?2 ?3)] [a b c] [A B C] [1 2 3])
; [aA1 bB2 cC3]
(foreach [a b c] [A B C] [1 2 3] [print (word ?1 ?2 ?3)]) ; as above, one per line
(foreach [a b c] [A B C] [1 2 3] [print (word ?1 ?2 ?3)]) ; as above,
one per line

View file

@ -3,6 +3,7 @@ LOOPMULU
S A(1)="a",A(2)="b",A(3)="c",A(4)="d"
S B(1)="A",B(2)="B",B(3)="C",B(4)="D"
S C(1)="1",C(2)="2",C(3)="3"
; will error S %=$O(A("")) F Q:%="" W !,A(%),B(%),C(%) S %=$O(A(%))
; will error S %=$O(A("")) F Q:%="" W !,A(%),B(%),C(%) S
%=$O(A(%))
S %=$O(A("")) F Q:%="" W !,$G(A(%)),$G(B(%)),$G(C(%)) S %=$O(A(%))
K A,B,C,D,%

View file

@ -11,6 +11,7 @@ VAR
BEGIN
FOR i := FIRST(ArrIdx) TO LAST(ArrIdx) DO
IO.Put(Fmt.Char(arr1[i]) & Fmt.Char(arr2[i]) & Fmt.Int(arr3[i]) & "\n");
IO.Put(Fmt.Char(arr1[i]) & Fmt.Char(arr2[i]) &
Fmt.Int(arr3[i]) & "\n");
END;
END MultiArray.

View file

@ -3,7 +3,8 @@ using System.Console;
module LoopMultiple
{
Zip3[T1, T2, T3] (x : list[T1], y : list[T2], z : list[T3]) : list[T1 * T2 * T3]
Zip3[T1, T2, T3] (x : list[T1], y : list[T2], z : list[T3]) :
list[T1 * T2 * T3]
{
|(x::xs, y::ys, z::zs) => (x, y, z)::Zip3(xs, ys, zs)
|([], [], []) => []

View file

@ -8,7 +8,8 @@ module LoopMult
def second = array['A', 'B', 'C'];
def third = array[1, 2, 3];
when (first.Length == second.Length && second.Length == third.Length)
when (first.Length == second.Length && second.Length ==
third.Length)
foreach (i in [0 .. (first.Length - 1)])
WriteLine("{0}{1}{2}", first[i], second[i], third[i]);
}

View file

@ -1 +1,2 @@
(map println '(a b c) '(A B C) '(1 2 3))
(map println '(a b c) '(A B C) '(1 2
3))

View file

@ -3,7 +3,8 @@ let n_arrays_iter ~f = function
| x::xs as al ->
let len = Array.length x in
let b = List.for_all (fun a -> Array.length a = len) xs in
if not b then invalid_arg "n_arrays_iter: arrays of different length";
if not b then invalid_arg "n_arrays_iter: arrays of different
length";
for i = 0 to pred len do
let ai = List.map (fun a -> a.(i)) al in
f ai

View file

@ -1 +1,2 @@
val n_arrays_iter : f:('a list -> unit) -> 'a array list -> unit
val n_arrays_iter : f:('a list -> unit) -> 'a
array list -> unit

View file

@ -1,6 +1,7 @@
$a = array('a', 'b', 'c');
$b = array('A', 'B', 'C');
$c = array('1', '2', '3'); //These don't *have* to be strings, but it saves PHP from casting them later
$c = array('1', '2', '3'); //These don't *have* to be strings, but it
saves PHP from casting them later
if ((sizeOf($a) !== sizeOf($b)) || (sizeOf($b) !== sizeOf($c))){
throw new Exception('All three arrays must be the same length');

View file

@ -1,3 +1 @@
for <a b c> Z~ <A B C> Z~ 1, 2, 3 -> $line {
say $line;
}
.say for <a b c> Z~ <A B C> Z~ 1, 2, 3;

View file

@ -2,7 +2,8 @@
/transpose {
[ exch {
{ {empty? exch pop} map all?} {pop exit} ift
[ exch {} {uncons {exch cons} dip exch} fold counttomark 1 roll] uncons
[ exch {} {uncons {exch cons} dip exch} fold counttomark 1 roll]
uncons
} loop ] {reverse} map
}.

View file

@ -1,4 +1,5 @@
>>> print ( '\n'.join(''.join(x) for x in zip('abc', 'ABC', '123')) )
>>> print ( '\n'.join(''.join(x) for x in
zip('abc', 'ABC', '123')) )
aA1
bB2
cC3

View file

@ -1,4 +1,5 @@
>>> print ( '\n'.join(map(lambda *x: ''.join(x), 'abc', 'ABC', '123')) )
>>> print ( '\n'.join(map(lambda *x:
''.join(x), 'abc', 'ABC', '123')) )
aA1
bB2
cC3

View file

@ -1,5 +1,6 @@
>>> from itertools import zip_longest
>>> print ( '\n'.join(''.join(x) for x in zip_longest('abc', 'ABCD', '12345', fillvalue='#')) )
>>> print ( '\n'.join(''.join(x) for x in zip_longest('abc',
'ABCD', '12345', fillvalue='#')) )
aA1
bB2
cC3

View file

@ -1,4 +1,5 @@
/*REXX program shows how to simultaneously loop over multiple arrays.*/
/*REXX program shows how to simultaneously loop over
multiple arrays.*/
x. = ' '; x.1 = "a"; x.2 = 'b'; x.3 = "c"
y. = ' '; y.1 = "A"; y.2 = 'B'; y.3 = "C"
z. = ' '; z.1 = "1"; z.2 = '2'; z.3 = "3"
@ -6,4 +7,5 @@ z. = ' '; z.1 = "1"; z.2 = '2'; z.3 = "3"
do j=1 until output=''
output = x.j || y.j || z.j
say output
end /*j*/ /*stick a fork in it, we're done.*/
end /*j*/ /*stick a fork in it, we're
done.*/

View file

@ -1,9 +1,12 @@
/*REXX program shows how to simultaneously loop over multiple arrays.*/
/*REXX program shows how to simultaneously loop over
multiple arrays.*/
x.=' '; x.1="a"; x.2='b'; x.3="c"; x.4='d'
y.=' '; y.1="A"; y.2='B'; y.3="C";
z.=' '; z.1= 1 ; z.2= 2 ; z.3= 3 ; z.4= 4; z.5= 5
z.=' '; z.1= 1 ; z.2= 2 ; z.3= 3 ; z.4= 4; z.5=
5
do j=1 until output=''
output=x.j || y.j || z.j
say output
end /*j*/ /*stick a fork in it, we're done.*/
end /*j*/ /*stick a fork in it, we're
done.*/

View file

@ -1,8 +1,10 @@
/*REXX program shows how to simultaneously loop over multiple lists.*/
/*REXX program shows how to simultaneously loop over
multiple lists.*/
x = 'a b c d'
y = 'A B C'
z = 1 2 3 4
do j=1 until output=''
output = word(x,j) || word(y,j) || word(z,j)
say output
end /*j*/ /*stick a fork in it, we're done.*/
end /*j*/ /*stick a fork in it, we're
done.*/

View file

@ -1,7 +1,9 @@
/*REXX program shows how to simultaneously loop over multiple lists.*/
/*REXX program shows how to simultaneously loop over
multiple lists.*/
x = 'a b c d'
y = 'A B C'
z = 1 2 3 4 ..LAST
do j=1 for max(words(x), words(y), words(z))
say word(x,j) || word(y,j) || word(z,j)
end /*j*/ /*stick a fork in it, we're done.*/
end /*j*/ /*stick a fork in it, we're
done.*/

View file

@ -1,6 +1,7 @@
#lang racket
(for ([i-1 '(a b c)]
[i-2 '(A B C)]
[i-3 '(1 2 3)])
(printf "~a ~a ~a~n" i-1 i-2 i-3))
(for ([x '(a b c)] ; list
[y #(A B C)] ; vector
[z "123"]
[i (in-naturals 1)]) ; 1, 2, ... infinitely
(printf "~s: ~s ~s ~s\n" i x y z))

View file

@ -0,0 +1,7 @@
irb(main):001:0> ['a','b','c'].zip(['A','B'], [1,2,3,4]) {|a| puts a.join}
aA1
bB2
c3
=> nil
irb(main):002:0> ['a','b','c'].zip(['A','B'], [1,2,3,4])
=> [["a", "A", 1], ["b", "B", 2], ["c", nil, 3]]

View file

@ -1,5 +1,3 @@
// rust 0.9-pre
fn main() {
let a1 = ["a", "b", "c"];
let a2 = ["A", "B", "C"];

View file

@ -1,4 +1,5 @@
// First, we'll define a general-purpose zip() to zip any
// First, we'll define a general-purpose zip() to zip
any
// number of lists together.
function zip(...)
{

View file

@ -1,4 +1,5 @@
// First, we'll define a general-purpose zip() to zip any
// First, we'll define a general-purpose zip() to zip
any
// number of lists together.
function zip(...)
{

View file

@ -2,7 +2,8 @@
* val combine_lists : string list list -> string list
*)
fun combine_lists nil = nil
| combine_lists (l1::ls) = List.foldl (ListPair.map (fn (x,y) => y ^ x)) l1 ls;
| combine_lists (l1::ls) = List.foldl (ListPair.map (fn (x,y) => y ^
x)) l1 ls;
(* ["a1Ax","b2By","c3Cz"] *)
combine_lists[["a","b","c"],["1","2","3"],["A","B","C"],["x","y","z"]];

View file

@ -1 +1,2 @@
([\a,\b,\c]+++[\A,\B,\C]+++[1,2,3]).do({|array| array.do(_.post); "".postln })
([\a,\b,\c]+++[\A,\B,\C]+++[1,2,3]).do({|array|
array.do(_.post); "".postln })

View file

@ -1,4 +1,5 @@
$ txr -e '(pprint (mappend (op list) "abc" "ABC" "123" (repeat "\n"))))'
$ txr -e '(pprint (mappend (op list) "abc" "ABC" "123"
(repeat "\n"))))'
aA1
bB2
cC3

View file

@ -1,4 +1,5 @@
$ txr -e '(each ((x "abc") (y "ABC") (z "123")) (put-line `@x@y@z`))'
$ txr -e '(each ((x "abc") (y "ABC") (z "123"))
(put-line `@x@y@z`))'
aA1
bB2
cC3

View file

@ -1,22 +1,22 @@
@(do
;; Scheme's vector-for-each: a one-liner in TXR
;; that happily works over strings and lists.
(defun vector-for-each (fun . vecs)
[apply mapcar fun (range) vecs])
;; Scheme's vector-for-each: a one-liner in TXR
;; that happily works over strings and lists.
;; We don't need "srfi-43".
(defun vector-for-each (fun . vecs)
[apply mapcar fun (range) vecs])
(defun display (obj : (stream *stdout*))
(pprint obj stream))
(defun display (obj : (stream *stdout*))
(pprint obj stream))
(defun newline (: (stream *stdout*))
(display #\newline stream))
(defun newline (: (stream *stdout*))
(display #\newline stream))
(let ((a (vec "a" "b" "c"))
(b (vec "A" "B" "C"))
(c (vec 1 2 3)))
(vector-for-each
(lambda (current-index i1 i2 i3)
(display i1)
(display i2)
(display i3)
(newline))
a b c)))
(let ((a (vec "a" "b" "c"))
(b (vec "A" "B" "C"))
(c (vec 1 2 3)))
(vector-for-each
(lambda (current-index i1 i2 i3)
(display i1)
(display i2)
(display i3)
(newline))
a b c))

View file

@ -1,17 +1,16 @@
@(do
(macro-time
(defun question-var-to-meta-num (var)
^(sys:var ,(int-str (cdr (symbol-name var))))))
(macro-time
(defun question-var-to-meta-num (var)
^(sys:var ,(int-str (cdr (symbol-name var))))))
(defmacro map (square-fun . square-args)
(tree-bind [(fun . args)] square-fun
^[apply mapcar (op ,fun ,*[mapcar question-var-to-meta-num args])
(macrolet ([(. args) ^(quote ,args)])
(list ,*square-args))]))
(defmacro map (square-fun . square-args)
(tree-bind [(fun . args)] square-fun
^[apply mapcar (op ,fun ,*[mapcar question-var-to-meta-num args])
(macrolet ([(. args) ^(quote ,args)])
(list ,*square-args))]))
(defun word (. items)
[apply format nil "~a~a~a" items])
(defun word (. items)
[apply format nil "~a~a~a" items])
(defun show (x) (pprinl x))
(defun show (x) (pprinl x))
(show (map [(word ?1 ?2 ?3)] [a b c] [A B C] [1 2 3])))
(show (map [(word ?1 ?2 ?3)] [a b c] [A B C] [1 2 3]))

View file

@ -1,6 +1,9 @@
a=(a b c)
b=(A B C)
c=(1 2 3)
for ((i = 0; i < ${#a[@]}; i++)); do
echo "${a[$i]}${b[$i]}${c[$i]}"
A='a1 a2 a3'
B='b1 b2 b3'
set -- $B
for a in $A
do
printf "$a $1\n"
shift
done

View file

@ -1,8 +1,6 @@
set -A a a b c
set -A b A B C
set -A c 1 2 3
((i = 0))
while ((i < ${#a[@]})); do
a=(a b c)
b=(A B C)
c=(1 2 3)
for ((i = 0; i < ${#a[@]}; i++)); do
echo "${a[$i]}${b[$i]}${c[$i]}"
((i++))
done

View file

@ -1,6 +1,8 @@
a=(a b c)
b=(A B C)
c=(1 2 3)
for ((i = 1; i <= $#a; i++)); do
echo "$a[$i]$b[$i]$c[$i]"
set -A a a b c
set -A b A B C
set -A c 1 2 3
((i = 0))
while ((i < ${#a[@]})); do
echo "${a[$i]}${b[$i]}${c[$i]}"
((i++))
done

View file

@ -1,8 +1,6 @@
set a=(a b c)
set b=(A B C)
set c=(1 2 3)
@ i = 1
while ( $i <= $#a )
echo "$a[$i]$b[$i]$c[$i]"
@ i += 1
end
a=(a b c)
b=(A B C)
c=(1 2 3)
for ((i = 1; i <= $#a; i++)); do
echo "$a[$i]$b[$i]$c[$i]"
done

View file

@ -0,0 +1,8 @@
set a=(a b c)
set b=(A B C)
set c=(1 2 3)
@ i = 1
while ( $i <= $#a )
echo "$a[$i]$b[$i]$c[$i]"
@ i += 1
end

View file

@ -6,7 +6,8 @@
60 IF szb > max THEN LET max = szb: REM now try b
70 IF szc > max THEN LET max = szc: REM or c
80 REM populate our arrays, and as a bonus we already have our demo loop
90 REM we might as well print as we populate showing the arrays in columns
90 REM we might as well print as we populate showing the arrays in
columns
100 FOR l = 1 TO max
110 IF l <= sza THEN READ a$(l): PRINT a$(l);
120 IF l <= szb THEN READ b$(l): PRINT b$(l);