CDE
This commit is contained in:
parent
518da4a923
commit
764da6cbbb
6144 changed files with 83610 additions and 11 deletions
14
Task/Array-concatenation/C++/array-concatenation.cpp
Normal file
14
Task/Array-concatenation/C++/array-concatenation.cpp
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
#include <vector>
|
||||
#include <iostream>
|
||||
|
||||
int main()
|
||||
{
|
||||
std::vector<int> a(3), b(4);
|
||||
a[0] = 11; a[1] = 12; a[2] = 13;
|
||||
b[0] = 21; b[1] = 22; b[2] = 23; b[3] = 24;
|
||||
|
||||
a.insert(a.end(), b.begin(), b.end());
|
||||
|
||||
for (int i = 0; i < a.size(); ++i)
|
||||
std::cout << "a[" << i << "] = " << a[i] << "\n";
|
||||
}
|
||||
22
Task/Array-concatenation/C-sharp/array-concatenation-1.cs
Normal file
22
Task/Array-concatenation/C-sharp/array-concatenation-1.cs
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
using System;
|
||||
|
||||
namespace RosettaCode
|
||||
{
|
||||
class Program
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
int[] a = { 1, 2, 3 };
|
||||
int[] b = { 4, 5, 6 };
|
||||
|
||||
int[] c = new int[a.Length + b.Length];
|
||||
a.CopyTo(c, 0);
|
||||
b.CopyTo(c, a.Length);
|
||||
|
||||
foreach(int n in c)
|
||||
{
|
||||
Console.WriteLine(n.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
12
Task/Array-concatenation/C-sharp/array-concatenation-2.cs
Normal file
12
Task/Array-concatenation/C-sharp/array-concatenation-2.cs
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
using System.Linq;
|
||||
|
||||
class Program
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
int[] a = { 1, 2, 3 };
|
||||
int[] b = { 4, 5, 6 };
|
||||
|
||||
int[] c = a.Concat(b).ToArray();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
(concatenate 'vector #(0 1 2 3) #(4 5 6 7))
|
||||
=> #(0 1 2 3 4 5 6 7)
|
||||
8
Task/Array-concatenation/D/array-concatenation.d
Normal file
8
Task/Array-concatenation/D/array-concatenation.d
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
import std.stdio: writeln;
|
||||
|
||||
void main() {
|
||||
int[] a = [1, 2];
|
||||
int[] b = [4, 5, 6];
|
||||
|
||||
writeln(a, " ~ ", b, " = ", a ~ b);
|
||||
}
|
||||
38
Task/Array-concatenation/Delphi/array-concatenation.delphi
Normal file
38
Task/Array-concatenation/Delphi/array-concatenation.delphi
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
type
|
||||
TReturnArray = array of integer; //you need to define a type to be able to return it
|
||||
|
||||
function ConcatArray(a1,a2:array of integer):TReturnArray;
|
||||
var
|
||||
i,r:integer;
|
||||
begin
|
||||
{ Low(array) is not necessarily 0 }
|
||||
SetLength(result,High(a1)-Low(a1)+High(a2)-Low(a2)+2); //BAD idea to set a length you won't release, just to show the idea!
|
||||
r:=0; //index on the result may be different to indexes on the sources
|
||||
for i := Low(a1) to High(a1) do begin
|
||||
result[r] := a1[i];
|
||||
Inc(r);
|
||||
end;
|
||||
for i := Low(a2) to High(a2) do begin
|
||||
result[r] := a2[i];
|
||||
Inc(r);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TForm1.Button1Click(Sender: TObject);
|
||||
var
|
||||
a1,a2:array of integer;
|
||||
r1:array of integer;
|
||||
i:integer;
|
||||
begin
|
||||
SetLength(a1,4);
|
||||
SetLength(a2,3);
|
||||
for i := Low(a1) to High(a1) do
|
||||
a1[i] := i;
|
||||
for i := Low(a2) to High(a2) do
|
||||
a2[i] := i;
|
||||
TReturnArray(r1) := ConcatArray(a1,a2);
|
||||
for i := Low(r1) to High(r1) do
|
||||
showMessage(IntToStr(r1[i]));
|
||||
Finalize(r1); //IMPORTANT!
|
||||
ShowMessage(IntToStr(High(r1)));
|
||||
end;
|
||||
2
Task/Array-concatenation/E/array-concatenation.e
Normal file
2
Task/Array-concatenation/E/array-concatenation.e
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
? [1,2] + [3,4]
|
||||
# value: [1, 2, 3, 4]
|
||||
13
Task/Array-concatenation/EGL/array-concatenation.egl
Normal file
13
Task/Array-concatenation/EGL/array-concatenation.egl
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
program ArrayConcatenation
|
||||
function main()
|
||||
a int[] = [ 1, 2, 3 ];
|
||||
b int[] = [ 4, 5, 6 ];
|
||||
c int[];
|
||||
c.appendAll(a);
|
||||
c.appendAll(b);
|
||||
|
||||
for (i int from 1 to c.getSize())
|
||||
SysLib.writeStdout("Element " :: i :: " = " :: c[i]);
|
||||
end
|
||||
end
|
||||
end
|
||||
11
Task/Array-concatenation/Efene/array-concatenation.efene
Normal file
11
Task/Array-concatenation/Efene/array-concatenation.efene
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
@public
|
||||
run = fn () {
|
||||
A = [1, 2, 3, 4]
|
||||
B = [5, 6, 7, 8]
|
||||
|
||||
C = A ++ B
|
||||
D = lists.append([A, B])
|
||||
|
||||
io.format("~p~n", [C])
|
||||
io.format("~p~n", [D])
|
||||
}
|
||||
11
Task/Array-concatenation/Elena/array-concatenation.elena
Normal file
11
Task/Array-concatenation/Elena/array-concatenation.elena
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
#define std'routines'arrays'*.
|
||||
|
||||
#symbol Program =
|
||||
[
|
||||
#var a := (1,2,3).
|
||||
#var b := (4,5).
|
||||
|
||||
#var c := a~earrayop add:b.
|
||||
|
||||
'program'output << "(" << a << ") + (" << b << ") = (" << c <<")%n".
|
||||
].
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
sequence s1,s2,s3
|
||||
s1 = {1,2,3}
|
||||
s2 = {4,5,6}
|
||||
s3 = s1 & s2
|
||||
? s3
|
||||
Loading…
Add table
Add a link
Reference in a new issue