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

@ -0,0 +1,30 @@
* Arrays 04/09/2015
ARRAYS PROLOG
* we use TA array with 1 as origin. So TA(1) to TA(20)
* ta(i)=ta(j)
L R1,J j
BCTR R1,0 -1
SLA R1,2 r1=(j-1)*4 (*4 by shift left)
L R0,TA(R1) load r0 with ta(j)
L R1,I i
BCTR R1,0 -1
SLA R1,2 r1=(i-1)*4 (*4 by shift left)
ST R0,TA(R1) store r0 to ta(i)
EPILOG
* Array of 20 integers (32 bits) (4 bytes)
TA DS 20F
* Initialized array of 10 integers (32 bits)
TB DC 10F'0'
* Initialized array of 10 integers (32 bits)
TC DC F'1',F'2',F'3',F'4',F'5',F'6',F'7',F'8',F'9',F'10'
* Array of 10 integers (16 bits)
TD DS 10H
* Array of 10 strings of 8 characters (initialized)
TE DC 10CL8' '
* Array of 10 double precision floating point reals (64 bits)
TF DS 10D
*
I DC F'2'
J DC F'4'
YREGS
END ARRAYS

View file

@ -0,0 +1,13 @@
TYPES: tty_int TYPE STANDARD TABLE OF i
WITH NON-UNIQUE DEFAULT KEY.
DATA(itab) = VALUE tty_int( ( 1 )
( 2 )
( 3 ) ).
INSERT 4 INTO TABLE itab.
APPEND 5 TO itab.
DELETE itab INDEX 1.
cl_demo_output=>display( itab ).
cl_demo_output=>display( itab[ 2 ] ).

View file

@ -1,3 +1 @@
#var anArray := (1, 2, 3).
system'console writeLine:(anArray@1).
#var aStaticArray := (1, 2, 3).

View file

@ -1,4 +1,4 @@
#var anArray := system'Array new &length:5.
anArray setAt:0:2.
system'console writeLine:(anArray@0).
#var anArray := system'Array new &length:3.
anArray@0 := 1.
anArray@1 := 2.
anArray@2 := 3.

View file

@ -0,0 +1,4 @@
#var(type:intarray,size:3)aStackAllocatedArray.
aStackAllocatedArray@0 := 1.
aStackAllocatedArray@1 := 2.
aStackAllocatedArray@2 := 3.

View file

@ -0,0 +1,6 @@
#var aDynamicArray := ArrayList new.
aDynamicArray += 1.
aDynamicArray += 2.
aDynamicArray += 4.
aDynamicArray@2 := 3.

View file

@ -0,0 +1,3 @@
system'console writeLine:(anArray@0).
system'console writeLine:(aStackAllocatedArray@1).
system'console writeLine:(aDynamicArray@2).

View file

@ -0,0 +1,8 @@
10 DATA 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
20 DIM A(9) ' Array with size 10 (9 is maximum subscript), all elements are set to 0
30 FOR I = 0 TO 9
40 READ A(I) ' Initialize by reading data
50 NEXT I
60 PRINT A(4) ' Get 4th element of array
70 A(4) = 400 ' Set 4th element of array
80 PRINT A(4)

View file

@ -11,9 +11,12 @@ var myArray2 = new Array("Item1","Item2");
var myArray3 = ["Item1", "Item2"];
// Assign a value to member [2] (length is now 3)
myArray[2] = 5;
myArray3[2] = 5;
var x = myArray[2] + myArray.length; // 8
// You can also add a member to an array with the push function (length is now 4)
myArray3.push('Test');
// Elisions are supported, but are buggy in some implementations
var y = [0,1,,]; // length 3, or 4 in buggy implementations

View file

@ -1,5 +1,5 @@
/* NetRexx */
options replace format comments java crossref savelog symbols nobinary
options replace format comments java crossref symbols nobinary
array = int[10]
array[0] = 42

View file

@ -1,2 +1,3 @@
$NumberArray = array(0, 1, 2, 3, 4, 5, 6);
$LetterArray = array("a", "b", "c", "d", "e", "f");
$simpleForm = ['apple', 'orange'];

View file

@ -1 +1 @@
$BlankArray = array();
echo $CustomKeyArray["b"]; // Returns C

View file

@ -1 +1 @@
$BlankArray[] = "Not Blank Anymore";
$BlankArray = array();

View file

@ -1 +1 @@
$AssignArray["CertainKey"] = "Value";
$BlankArray[] = "Not Blank Anymore";

View file

@ -0,0 +1 @@
$AssignArray["CertainKey"] = "Value";

View file

@ -1,2 +1,3 @@
echo $NumberArray[5]; // Returns 5
echo $LetterArray[5]; // Returns f
$arr = ['apple', 'orange'];
array_push($arr, 'pear');
print implode(',', $arr); // Returns apple,orange,pear

View file

@ -1 +1,2 @@
echo $MultiArray[1][5]; // 2
echo $NumberArray[5]; // Returns 5
echo $LetterArray[5]; // Returns f

View file

@ -1 +1 @@
print_r($MultiArray);
echo $MultiArray[1][5]; // 2

View file

@ -1,34 +1 @@
Array(
0 => array(
0 => 0
1 => 0
2 => 0
3 => 0
4 => 0
5 => 0
)
1 => array(
0 => 1
1 => 1
2 => 1
3 => 1
4 => 1
5 => 1
)
2 => array(
0 => 2
1 => 2
2 => 2
3 => 2
4 => 2
5 => 2
)
3 => array(
0 => 3
1 => 3
2 => 3
3 => 3
4 => 3
5 => 3
)
)
print_r($MultiArray);

View file

@ -1 +1,34 @@
$StartIndexAtOne = array(1 => "A", "B", "C", "D");
Array(
0 => array(
0 => 0
1 => 0
2 => 0
3 => 0
4 => 0
5 => 0
)
1 => array(
0 => 1
1 => 1
2 => 1
3 => 1
4 => 1
5 => 1
)
2 => array(
0 => 2
1 => 2
2 => 2
3 => 2
4 => 2
5 => 2
)
3 => array(
0 => 3
1 => 3
2 => 3
3 => 3
4 => 3
5 => 3
)
)

View file

@ -1 +1 @@
$CustomKeyArray = array("d" => "A", "c" => "B", "b" =>"C", "a" =>"D");
$StartIndexAtOne = array(1 => "A", "B", "C", "D");

View file

@ -1 +1 @@
echo $CustomKeyArray["b"]; // Returns C
$CustomKeyArray = array("d" => "A", "c" => "B", "b" =>"C", "a" =>"D");

View file

@ -0,0 +1,3 @@
let a = [1, 2, 3]; // immutable array
let mut m = [1, 2, 3]; // mutable array
let zeroes = [0; 200]; // creates an array of 200 zeroes

View file

@ -0,0 +1,5 @@
let a = [1, 2, 3];
a.len();
for e in a.iter() {
e;
}

View file

@ -0,0 +1,2 @@
let names = ["Graydon", "Brian", "Niko"];
names[1]; // second element

View file

@ -0,0 +1 @@
let v = vec![1, 2, 3];

View file

@ -0,0 +1,3 @@
let mut v = vec![1, 2, 3];
v.push(4);
v.len(); // 4

View file

@ -0,0 +1 @@
vector copySize: 100

View file

@ -0,0 +1 @@
vector copySize: 100 FillingWith: anObject

View file

@ -0,0 +1 @@
(1 & 'Hello' & 2.0 & someObject) asVector

View file

@ -0,0 +1,9 @@
|v|
"creates an vector that holds up to 20 elements"
v: vector copySize: 20.
"access the first element"
v first printLine.
"access the 10th element"
(v at: 9) printLine.
"put 100 as second value"
vat: 1 Put: 100.

View file

@ -0,0 +1,3 @@
v do: [:each | each printLine].
v copy mapBy: [:each | each squared].
v copy filterBy: [:each | each > 10].

View file

@ -0,0 +1,11 @@
|s|
"creates a new sequence"
s: sequence copyRemoveAll.
"add an element"
s addLast: 'Hello'.
"access the first element"
s first printLine.
"remove the first element"
s removeFirst.
"Check size"
s size printLine.

View file

@ -0,0 +1,4 @@
20→dim(L1)
DelVar L1
5→dim(∟MYLIST)
DelVar ∟MYLIST

View file

@ -0,0 +1,3 @@
[[11,21,31,41][12,22,32,42][13,23,33,43]]→[A]
Disp [A](1,3)
0→[A](4,2)

View file

@ -0,0 +1,2 @@
{5,5}→dim([A])
DelVar [A]

View file

@ -1,31 +1,31 @@
'Example of array of 10 int types:
Dim numbers As Integer() = New Integer(0) {}
'Example of array of 4 string types:
Dim words As String() = {"hello", "world", "from", "mars"}
'You can also declare the size of the array and initialize the values at the same time:
Dim more_numbers As Integer() = New Integer(2) {21, 14, 63}
'Example of array of 10 int types:
Dim numbers As Integer() = New Integer(0) {}
'Example of array of 4 string types:
Dim words As String() = {"hello", "world", "from", "mars"}
'You can also declare the size of the array and initialize the values at the same time:
Dim more_numbers As Integer() = New Integer(2) {21, 14, 63}
'For Multi-Dimensional arrays you declare them the same except for a comma in the type declaration.
'The following creates a 3x2 int matrix
Dim number_matrix As Integer(,) = New Integer(2, 1) {}
'For Multi-Dimensional arrays you declare them the same except for a comma in the type declaration.
'The following creates a 3x2 int matrix
Dim number_matrix As Integer(,) = New Integer(2, 1) {}
'As with the previous examples you can also initialize the values of the array, the only difference being each row in the matrix must be enclosed in its own braces.
Dim string_matrix As String(,) = {{"I", "swam"}, {"in", "the"}, {"freezing", "water"}}
'or
Dim funny_matrix As String(,) = New String(1, 1) {{"clowns", "are"}, {"not", "funny"}}
'As with the previous examples you can also initialize the values of the array, the only difference being each row in the matrix must be enclosed in its own braces.
Dim string_matrix As String(,) = {{"I", "swam"}, {"in", "the"}, {"freezing", "water"}}
'or
Dim funny_matrix As String(,) = New String(1, 1) {{"clowns", "are"}, {"not", "funny"}}
Dim array As Integer() = New Integer(9) {}
array(0) = 1
array(1) = 3
Console.WriteLine(array(0))
Dim array As Integer() = New Integer(9) {}
array(0) = 1
array(1) = 3
Console.WriteLine(array(0))
'Dynamic
Imports System
Imports System.Collections.Generic
Dim list As New List(Of Integer)()
list.Add(1)
list.Add(3)
list(0) = 2
Console.WriteLine(list(0))
'Dynamic
Imports System
Imports System.Collections.Generic
Dim list As New List(Of Integer)()
list.Add(1)
list.Add(3)
list(0) = 2
Console.WriteLine(list(0))