September Morn Update
This commit is contained in:
parent
4e2d22a71d
commit
aac6731f2c
6856 changed files with 141342 additions and 21127 deletions
|
|
@ -33,4 +33,6 @@ If possible, also describe what happens when the arrays are of different lengths
|
|||
* [[Loops/N plus one half]]
|
||||
* [[Loops/Nested]]
|
||||
* [[Loops/While]]
|
||||
* [[Loops/with multiple ranges]]
|
||||
* [[Loops/Wrong ranges]]
|
||||
<br><br>
|
||||
|
|
|
|||
|
|
@ -1,15 +1,18 @@
|
|||
import extensions.
|
||||
import system'routines;
|
||||
import extensions;
|
||||
|
||||
program =
|
||||
[
|
||||
var a1 := ("a","b","c").
|
||||
var a2 := ("A","B","C").
|
||||
var a3 := (1,2,3).
|
||||
public program()
|
||||
{
|
||||
var a1 := new string[]{"a","b","c"};
|
||||
var a2 := new string[]{"A","B","C"};
|
||||
var a3 := new int[]{1,2,3};
|
||||
|
||||
0 till(a1 length) do(:i)
|
||||
[
|
||||
console printLine(a1[i], a2[i], a3[i]).
|
||||
].
|
||||
for(int i := 0, i < a1.Length, i += 1)
|
||||
{
|
||||
console.printLine(a1[i], a2[i], a3[i])
|
||||
};
|
||||
|
||||
console readChar.
|
||||
].
|
||||
programUsingZip();
|
||||
|
||||
console.readChar()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,16 +1,16 @@
|
|||
import system'routines.
|
||||
import extensions.
|
||||
|
||||
program =
|
||||
[
|
||||
var a1 := ("a","b","c").
|
||||
var a2 := ("A","B","C").
|
||||
var a3 := (1,2,3).
|
||||
var zipped := a1 zip:a2 by(:first:second)( first + second );
|
||||
zip:a3 by(:first:second)( first + second literal ).
|
||||
public program
|
||||
{
|
||||
var a1 := new string[]{"a","b","c"};
|
||||
var a2 := new string[]{"A","B","C"};
|
||||
var a3 := new int[]{1,2,3};
|
||||
var zipped := a1.zipBy(a2,(first,second => first + second.toString() ))
|
||||
.zipBy(a3, (first,second => first + second.toString() ));
|
||||
|
||||
zipped forEach(:e)
|
||||
[ console writeLine:e. ].
|
||||
zipped.forEach:(e)
|
||||
{ console.writeLine:e };
|
||||
|
||||
console readChar.
|
||||
].
|
||||
console.readChar();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,10 @@
|
|||
PROCEDURE Main()
|
||||
LOCAL a1 := { "a", "b", "c" }, ;
|
||||
a2 := { "A", "B", "C", "D" }, ; // the last element "D" of this array will be ignored
|
||||
a3 := { 1, 2, 3 }
|
||||
LOCAL e1, e2, e3
|
||||
|
||||
FOR EACH e1, e2, e3 IN a1, a2, a3
|
||||
Qout( e1 + e2 + hb_ntos( e3 ) )
|
||||
NEXT
|
||||
RETURN
|
||||
|
|
@ -1,5 +1,4 @@
|
|||
>>> print ( '\n'.join(map(lambda *x:
|
||||
''.join(x), 'abc', 'ABC', '123')) )
|
||||
>>> print(*map(''.join, zip('abc', 'ABC', '123')), sep='\n')
|
||||
aA1
|
||||
bB2
|
||||
cC3
|
||||
|
|
|
|||
|
|
@ -0,0 +1,18 @@
|
|||
Module Program
|
||||
Sub Main()
|
||||
Dim a As Char() = {"a"c, "b"c, "c"c}
|
||||
Dim b As Char() = {"A"c, "B"c, "C"c}
|
||||
Dim c As Integer() = {1, 2, 3}
|
||||
|
||||
Dim minLength = {a.Length, b.Length, c.Length}.Min()
|
||||
For i = 0 To minLength - 1
|
||||
Console.WriteLine(a(i) & b(i) & c(i))
|
||||
Next
|
||||
|
||||
Console.WriteLine()
|
||||
|
||||
For Each el As (a As Char, b As Char, c As Integer) In a.Zip(b, Function(l, r) (l, r)).Zip(c, Function(x, r) (x.l, x.r, r))
|
||||
Console.WriteLine(el.a & el.b & el.c)
|
||||
Next
|
||||
End Sub
|
||||
End Module
|
||||
Loading…
Add table
Add a link
Reference in a new issue