Just another update

This commit is contained in:
Ingy döt Net 2015-02-20 00:35:01 -05:00
parent a25938f123
commit 00a190b0a6
6591 changed files with 94363 additions and 23227 deletions

View file

@ -1,4 +1,5 @@
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
<pre>aA1

View file

@ -0,0 +1,11 @@
#include <stdio.h>
char a1[] = {'a','b','c'};
char a2[] = {'A','B','C'};
int a3[] = {1,2,3};
int main(void) {
for (int i = 0; i < 3; i++) {
printf("%c%c%i\n", a1[i], a2[i], a3[i]);
}
}

View file

@ -2,12 +2,12 @@ package main
import "fmt"
var a1 = []int{'a','b','c'}
var a2 = []int{'A','B','C'}
var a3 = []int{1,2,3}
var a1 = []string{"a", "b", "c"}
var a2 = []byte{'A', 'B', 'C'}
var a3 = []int{1, 2, 3}
func main() {
for i := range a1 {
fmt.Printf("%c%c%d\n", a1[i], a2[i], a3[i])
}
for i := range a1 {
fmt.Printf("%v%c%v\n", a1[i], a2[i], a3[i])
}
}

View file

@ -1 +1,4 @@
,.&:(":"0@>)/ 'abc' ; 'ABC' ; 1 2 3
,.&:(":"0@>)/ 'abc' ; 'ABC' ; 1 2 3
aA1
bB2
cC3

View file

@ -1 +1,4 @@
,.&:>/ 'abc' ; 'ABC' ; '123'
,.&:>/ 'abc' ; 'ABC' ; '123'
aA1
bB2
cC3

View file

@ -1 +1,4 @@
|: 'abc', 'ABC' ,:;":&> 1 2 3
|: 'abc', 'ABC' ,:;":&> 1 2 3
aA1
bB2
cC3

View file

@ -1 +1,4 @@
|: 'abc', 'ABC',: '123'
|: 'abc', 'ABC',: '123'
aA1
bB2
cC3

View file

@ -1 +1,8 @@
|:>]&.>L:_1 'abc';'ABC';<1 2 3
|:>]&.>L:_1 'abc';'ABC';<1 2 3
┌─┬─┬─┐
│a│A│1│
├─┼─┼─┤
│b│B│2│
├─┼─┼─┤
│c│C│3│
└─┴─┴─┘

View file

@ -1,6 +1,6 @@
String[] a = {"a","b","c"};
String[] b = {"A","B","C"};
int[] c = {1,2,3};
for (int i = 0;i < a.length;i++) {
System.out.println(a[i] + b[i] + c[i] + "\n");
for(int i = 0;i < a.length;i++){
System.out.println(a[i] + b[i] + c[i]);
}

View file

@ -1 +1 @@
&/#:'x
{+x[;!(&/#:'x)]}("abc";"ABC";"1234")

View file

@ -1 +1 @@
{+x[;!(&/#:'x)]}("abc";"ABC";"1234")
{a:,/'($:'x);+a[;!(&/#:'a)]}("abc";"ABC";1 2 3 4)

View file

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

View file

@ -0,0 +1,24 @@
MODULE LoopMArrays;
IMPORT
Out;
VAR
x,y: ARRAY 3 OF CHAR;
z: ARRAY 3 OF INTEGER;
PROCEDURE DoLoop;
VAR
i: INTEGER;
BEGIN
i := 0;
WHILE i < LEN(x) DO
Out.Char(x[i]);Out.Char(y[i]);Out.LongInt(z[i],0);Out.Ln;
INC(i)
END
END DoLoop;
BEGIN
x[0] := 'a';y[0] := 'A';z[0] := 1;
x[1] := 'b';y[1] := 'B';z[1] := 2;
x[2] := 'c';y[2] := 'C';z[2] := 3;
DoLoop
END LoopMArrays.

View file

@ -1,11 +1,9 @@
/*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"
do j=1 until output=''
output=x.j || y.j || z.j
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,11 +1,9 @@
/*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
do j=1 until output=''
output= x.j || y.j || z.j
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

@ -0,0 +1,8 @@
/*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.*/

View file

@ -0,0 +1,7 @@
/*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.*/

View file

@ -1 +1 @@
['a','b','c'].zip(['A','B','C'], [1,2,3]) {|a| puts a.join('')}
['a','b','c'].zip(['A','B','C'], [1,2,3]) {|a| puts a.join}