Data update
This commit is contained in:
parent
5150844a7d
commit
4bb20c9b71
7735 changed files with 38060 additions and 199180 deletions
|
|
@ -1,32 +0,0 @@
|
|||
with Ada.Integer_Text_Io; use Ada.Integer_Text_Io;
|
||||
with Ada.Text_Io; use Ada.Text_Io;
|
||||
|
||||
procedure Array_Selection is
|
||||
type Array_Type is array (Positive range <>) of Integer;
|
||||
Null_Array : Array_Type(1..0);
|
||||
|
||||
function Evens (Item : Array_Type) return Array_Type is
|
||||
begin
|
||||
if Item'Length > 0 then
|
||||
if Item(Item'First) mod 2 = 0 then
|
||||
return Item(Item'First) & Evens(Item((Item'First + 1)..Item'Last));
|
||||
else
|
||||
return Evens(Item((Item'First + 1)..Item'Last));
|
||||
end if;
|
||||
else
|
||||
return Null_Array;
|
||||
end if;
|
||||
end Evens;
|
||||
|
||||
procedure Print(Item : Array_Type) is
|
||||
begin
|
||||
for I in Item'range loop
|
||||
Put(Item(I));
|
||||
New_Line;
|
||||
end loop;
|
||||
end Print;
|
||||
|
||||
Foo : Array_Type := (1,2,3,4,5,6,7,8,9,10);
|
||||
begin
|
||||
Print(Evens(Foo));
|
||||
end Array_Selection;
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
with Ada.Text_IO; use Ada.Text_IO;
|
||||
|
||||
procedure Array_Selection is
|
||||
type Array_Type is array (Positive range <>) of Integer;
|
||||
|
||||
function Evens (Item : Array_Type) return Array_Type is
|
||||
Result : Array_Type (1..Item'Length);
|
||||
Index : Positive := 1;
|
||||
begin
|
||||
for I in Item'Range loop
|
||||
if Item (I) mod 2 = 0 then
|
||||
Result (Index) := Item (I);
|
||||
Index := Index + 1;
|
||||
end if;
|
||||
end loop;
|
||||
return Result (1..Index - 1);
|
||||
end Evens;
|
||||
|
||||
procedure Put (Item : Array_Type) is
|
||||
begin
|
||||
for I in Item'range loop
|
||||
Put (Integer'Image (Item (I)));
|
||||
end loop;
|
||||
end Put;
|
||||
begin
|
||||
Put (Evens ((1,2,3,4,5,6,7,8,9,10)));
|
||||
New_Line;
|
||||
end Array_Selection;
|
||||
|
|
@ -3,7 +3,7 @@ import system'math;
|
|||
import extensions;
|
||||
import extensions'routines;
|
||||
|
||||
public program()
|
||||
public Program()
|
||||
{
|
||||
auto array := new int[]{1,2,3,4,5};
|
||||
|
||||
|
|
|
|||
|
|
@ -3,9 +3,9 @@ import system'routines'stex;
|
|||
import system'math;
|
||||
import extensions;
|
||||
|
||||
public program()
|
||||
public Program()
|
||||
{
|
||||
int[] array := new int[]{1,2,3,4,5};
|
||||
int[] array := new []{1,2,3,4,5};
|
||||
|
||||
array
|
||||
.filterBy::(int n => n.mod(2) == 0)
|
||||
|
|
|
|||
|
|
@ -1 +0,0 @@
|
|||
(seq-filter (lambda (x) (= (% x 2))) '(1 2 3 4 5 6 7 8 9 10))
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
sequence s, evens
|
||||
s = {1, 2, 3, 4, 5, 6}
|
||||
evens = {}
|
||||
for i = 1 to length(s) do
|
||||
if remainder(s[i], 2) = 0 then
|
||||
evens = append(evens, s[i])
|
||||
end if
|
||||
end for
|
||||
? evens
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
$array = -15..37
|
||||
$array | Where-Object { $_ % 2 -eq 0 }
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
a: [] repeat i 100 [append a i] ; Build and load array.
|
||||
|
||||
evens: [] repeat element a [if even? element [append evens element]]
|
||||
|
||||
print mold evens
|
||||
|
|
@ -1,47 +0,0 @@
|
|||
test_arr_1 = Array(1,2,3,4,5,6,7,8,9,10)
|
||||
test_arr_2 = Array(1,2,3,4,5,6,7,8,9,10)
|
||||
|
||||
WScript.StdOut.Write "Scenario 1: Create a new array"
|
||||
WScript.StdOut.WriteLine
|
||||
WScript.StdOut.Write "Input: " & Join(test_arr_1,",")
|
||||
WScript.StdOut.WriteLine
|
||||
WScript.StdOut.Write "Output: " & filter_create(test_arr_1)
|
||||
WScript.StdOut.WriteBlankLines(2)
|
||||
|
||||
WScript.StdOut.Write "Scenario 2: Destructive approach"
|
||||
WScript.StdOut.WriteLine
|
||||
WScript.StdOut.Write "Input: " & Join(test_arr_2,",")
|
||||
WScript.StdOut.WriteLine
|
||||
WScript.StdOut.Write "Output: " & filter_destruct(test_arr_2)
|
||||
WScript.StdOut.WriteBlankLines(2)
|
||||
|
||||
Function filter_create(arr)
|
||||
ReDim arr_new(0)
|
||||
For i = 0 To UBound(arr)
|
||||
If arr(i) Mod 2 = 0 Then
|
||||
If arr_new(0) = "" Then
|
||||
arr_new(0) = arr(i)
|
||||
Else
|
||||
ReDim Preserve arr_new(UBound(arr_new)+1)
|
||||
arr_new(UBound(arr_new)) = arr(i)
|
||||
End If
|
||||
End If
|
||||
Next
|
||||
filter_create = Join(arr_new,",")
|
||||
End Function
|
||||
|
||||
Function filter_destruct(arr)
|
||||
count = 0
|
||||
For i = 0 To UBound(arr)
|
||||
If arr(i) Mod 2 <> 0 Then
|
||||
count = count + 1
|
||||
For j = i To UBound(arr)
|
||||
If j + 1 <= UBound(arr) Then
|
||||
arr(j) = arr(j+1)
|
||||
End If
|
||||
Next
|
||||
End If
|
||||
Next
|
||||
ReDim Preserve arr(UBound(arr)-count)
|
||||
filter_destruct = Join(arr,",")
|
||||
End Function
|
||||
Loading…
Add table
Add a link
Reference in a new issue