new files
This commit is contained in:
parent
3af7344581
commit
86c034bb8b
1364 changed files with 21352 additions and 0 deletions
1
Task/Collections/AWK/collections-1.awk
Normal file
1
Task/Collections/AWK/collections-1.awk
Normal file
|
|
@ -0,0 +1 @@
|
|||
a[0]="hello"
|
||||
11
Task/Collections/Ada/collections-1.ada
Normal file
11
Task/Collections/Ada/collections-1.ada
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
procedure Array_Collection is
|
||||
|
||||
A : array (-3 .. -1) of Integer := (1, 2, 3);
|
||||
|
||||
begin
|
||||
|
||||
A (-3) := 3;
|
||||
A (-2) := 2;
|
||||
A (-1) := 1;
|
||||
|
||||
end Array_Collection;
|
||||
12
Task/Collections/Ada/collections-2.ada
Normal file
12
Task/Collections/Ada/collections-2.ada
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
procedure Array_Collection is
|
||||
|
||||
type Array_Type is array (1 .. 3) of Integer;
|
||||
A : Array_Type := (1, 2, 3);
|
||||
|
||||
begin
|
||||
|
||||
A (1) := 3;
|
||||
A (2) := 2;
|
||||
A (3) := 1;
|
||||
|
||||
end Array_Collection;
|
||||
13
Task/Collections/Ada/collections-3.ada
Normal file
13
Task/Collections/Ada/collections-3.ada
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
procedure Array_Collection is
|
||||
|
||||
type Array_Type is array (positive range <>) of Integer; -- may be indexed with any positive
|
||||
-- Integer value
|
||||
A : Array_Type(1 .. 3); -- creates an array of three integers, indexed from 1 to 3
|
||||
|
||||
begin
|
||||
|
||||
A (1) := 3;
|
||||
A (2) := 2;
|
||||
A (3) := 1;
|
||||
|
||||
end Array_Collection;
|
||||
17
Task/Collections/Ada/collections-4.ada
Normal file
17
Task/Collections/Ada/collections-4.ada
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
with Ada.Containers.Doubly_Linked_Lists;
|
||||
use Ada.Containers;
|
||||
|
||||
procedure Doubly_Linked_List is
|
||||
|
||||
package DL_List_Pkg is new Doubly_Linked_Lists (Integer);
|
||||
use DL_List_Pkg;
|
||||
|
||||
DL_List : List;
|
||||
|
||||
begin
|
||||
|
||||
DL_List.Append (1);
|
||||
DL_List.Append (2);
|
||||
DL_List.Append (3);
|
||||
|
||||
end Doubly_Linked_List;
|
||||
17
Task/Collections/Ada/collections-5.ada
Normal file
17
Task/Collections/Ada/collections-5.ada
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
with Ada.Containers.Vectors;
|
||||
use Ada.Containers;
|
||||
|
||||
procedure Vector_Example is
|
||||
|
||||
package Vector_Pkg is new Vectors (Natural, Integer);
|
||||
use Vector_Pkg;
|
||||
|
||||
V : Vector;
|
||||
|
||||
begin
|
||||
|
||||
V.Append (1);
|
||||
V.Append (2);
|
||||
V.Append (3);
|
||||
|
||||
end Vector_Example;
|
||||
11
Task/Collections/C/collections-1.c
Normal file
11
Task/Collections/C/collections-1.c
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
#define cSize( a ) ( sizeof(a)/sizeof(a[0]) ) /* a.size() */
|
||||
int ar[10]; /* Collection<Integer> ar = new ArrayList<Integer>(10); */
|
||||
ar[0] = 1; /* ar.set(0, 1); */
|
||||
ar[1] = 2;
|
||||
|
||||
int* p; /* Iterator<Integer> p; Integer pValue; */
|
||||
for (p=ar; /* for( p = ar.itereator(), pValue=p.next(); */
|
||||
p<(ar+cSize(ar)); /* p.hasNext(); */
|
||||
p++) { /* pValue=p.next() ) { */
|
||||
printf("%d\n",*p); /* System.out.println(pValue); */
|
||||
} /* } */
|
||||
4
Task/Collections/Clojure/collections-1.clj
Normal file
4
Task/Collections/Clojure/collections-1.clj
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
{1 "a", "Q" 10} ; commas are treated as whitespace
|
||||
(hash-map 1 "a" "Q" 10) ; equivalent to the above
|
||||
(let [my-map {1 "a"}]
|
||||
(assoc my-map "Q" 10)) ; "adding" an element
|
||||
7
Task/Collections/Forth/collections-1.fth
Normal file
7
Task/Collections/Forth/collections-1.fth
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
include ffl/car.fs
|
||||
|
||||
10 car-create ar \ create a dynamic array with initial size 10
|
||||
|
||||
2 0 ar car-set \ ar[0] = 2
|
||||
3 1 ar car-set \ ar[1] = 3
|
||||
1 0 ar car-insert \ ar[0] = 1 ar[1] = 2 ar[2] = 3
|
||||
1
Task/Collections/Haskell/collections-1.hs
Normal file
1
Task/Collections/Haskell/collections-1.hs
Normal file
|
|
@ -0,0 +1 @@
|
|||
[1, 2, 3, 4, 5]
|
||||
14
Task/Collections/Java/collections-1.java
Normal file
14
Task/Collections/Java/collections-1.java
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
List arrayList = new ArrayList();
|
||||
arrayList.add(new Integer(0));
|
||||
// alternative with primitive autoboxed to an Integer object automatically
|
||||
arrayList.add(0);
|
||||
|
||||
//other features of ArrayList
|
||||
//define the type in the arraylist, you can substitute a proprietary class in the "<>"
|
||||
List<Integer> myarrlist = new ArrayList<Integer>();
|
||||
|
||||
//add several values to the arraylist to be summed later
|
||||
int sum;
|
||||
for(int i = 0; i < 10; i++) {
|
||||
myarrlist.add(i);
|
||||
}
|
||||
5
Task/Collections/JavaScript/collections-1.js
Normal file
5
Task/Collections/JavaScript/collections-1.js
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
var array = [];
|
||||
array.push('abc');
|
||||
array.push(123);
|
||||
array.push(new MyClass);
|
||||
alert( array[2] );
|
||||
3
Task/Collections/R/collections-1.r
Normal file
3
Task/Collections/R/collections-1.r
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
numeric(5)
|
||||
1:10
|
||||
c(1, 3, 6, 10, 7 + 8, sqrt(441))
|
||||
36
Task/Collections/REXX/collections-1.rexx
Normal file
36
Task/Collections/REXX/collections-1.rexx
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
pr.=0 /*define a default for all elements for the stemmed array.*/
|
||||
|
||||
pr.1 =2 /*note that this array starts at 1 (one). */
|
||||
pr.2 =3
|
||||
pr.3 =5
|
||||
pr.4 =7
|
||||
pr.6 =11
|
||||
pr.6 =13
|
||||
pr.7 =17
|
||||
pr.8 =19
|
||||
pr.9 =23
|
||||
pr.10=29
|
||||
pr.11=31
|
||||
pr.12=37
|
||||
pr.13=41
|
||||
pr.14=43
|
||||
|
||||
y.=0 /*define a default for all years. */
|
||||
y.1985 = 6020
|
||||
y.1986 = 7791
|
||||
y.1987 = 8244
|
||||
y.1988 = 10075
|
||||
x = y.2000 /*X will have a value of zero (0). */
|
||||
|
||||
fib.0 = 0 /*arrays may start with zero (0). */
|
||||
fib.1 = 1
|
||||
fib.2 = 1
|
||||
fib.3 = 2
|
||||
fib.4 = 3
|
||||
fib.5 = 5
|
||||
fib.6 = 8
|
||||
fib.7 =17
|
||||
|
||||
do n=-5 to 5 /*define an array from -5 ──► 5 */
|
||||
sawtooth.n=n
|
||||
end /*n*/ /*eleven elements will be defined. */
|
||||
8
Task/Collections/Ruby/collections-1.rb
Normal file
8
Task/Collections/Ruby/collections-1.rb
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
# creating an empty array and adding values
|
||||
|
||||
a = [] # => []
|
||||
a[0] = 1 # => [1]
|
||||
a[3] = 2 # => [1, nil, nil, 2]
|
||||
|
||||
# creating an array with the constructor
|
||||
a = Array.new # => []
|
||||
1
Task/Collections/Scheme/collections-1.ss
Normal file
1
Task/Collections/Scheme/collections-1.ss
Normal file
|
|
@ -0,0 +1 @@
|
|||
(list obj ...)
|
||||
12
Task/Collections/Tcl/collections-1.tcl
Normal file
12
Task/Collections/Tcl/collections-1.tcl
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
set c [list] ;# create an empty list
|
||||
# fill it
|
||||
lappend c 10 11 13
|
||||
set c [linsert $c 2 "twelve goes here"]
|
||||
# iterate over it
|
||||
foreach elem $c {puts $elem}
|
||||
|
||||
# pass to a proc
|
||||
proc show_size {l} {
|
||||
puts [llength $l]
|
||||
}
|
||||
show_size $c
|
||||
Loading…
Add table
Add a link
Reference in a new issue