Another update from ingydotnet^djgoku
This commit is contained in:
parent
91df62d461
commit
948b86eafa
7604 changed files with 108452 additions and 22726 deletions
|
|
@ -1 +1,2 @@
|
|||
Show how to concatenate two arrays in your language. If this is as simple as <code><var>array1</var> + <var>array2</var></code>, so be it.
|
||||
Show how to concatenate two arrays in your language.
|
||||
If this is as simple as <code><var>array1</var> + <var>array2</var></code>, so be it.
|
||||
|
|
|
|||
|
|
@ -1,2 +1,4 @@
|
|||
---
|
||||
category:
|
||||
- Simple
|
||||
note: Data Structures
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
#define system.
|
||||
#define extensions.
|
||||
|
||||
#symbol program =
|
||||
|
|
@ -5,5 +6,5 @@
|
|||
#var a := (1,2,3).
|
||||
#var b := (4,5).
|
||||
|
||||
consoleEx writeLine:"(":a:") + (":b:") = (":(a + b):")".
|
||||
console writeLine:"(":a:") + (":b:") = (":(a + b):")".
|
||||
].
|
||||
|
|
|
|||
|
|
@ -0,0 +1,6 @@
|
|||
iex(1)> [1, 2, 3] ++ [4, 5, 6]
|
||||
[1, 2, 3, 4, 5, 6]
|
||||
iex(2)> Enum.concat([[1, [2], 3], [4], [5, 6]])
|
||||
[1, [2], 3, 4, 5, 6]
|
||||
iex(3)> Enum.concat([1..3, [4,5,6], 7..9])
|
||||
[1, 2, 3, 4, 5, 6, 7, 8, 9]
|
||||
|
|
@ -1,4 +1,3 @@
|
|||
var
|
||||
a = [1,2,3],
|
||||
b = [4,5,6],
|
||||
c = a.concat(b); // [1,2,3,4,5,6]
|
||||
var a = [1,2,3],
|
||||
b = [4,5,6],
|
||||
c = a.concat(b); //=> [1,2,3,4,5,6]
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* NetRexx */
|
||||
options replace format comments java crossref savelog symbols nobinary
|
||||
options replace format comments java crossref nobinary
|
||||
|
||||
cymru = [ 'Ogof Ffynnon Ddu', 'Ogof Draenen' ]
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
# the comma ',' can be used to concatenate arrays:
|
||||
sub concatenateArrays(@a, @b) {
|
||||
@a, @b
|
||||
# the prefix:<|> operator (called "slip") can be used to interpolate arrays into a list:
|
||||
sub cat-arrays(@a, @b) {
|
||||
|@a, |@b
|
||||
}
|
||||
|
||||
my @a1 = (1,2,3);
|
||||
my @a2 = (2,3,4);
|
||||
concatenateArrays(@a1,@a2).join(", ").say;
|
||||
cat-arrays(@a1,@a2).join(", ").say;
|
||||
|
|
|
|||
4
Task/Array-concatenation/Ruby/array-concatenation-2.rb
Normal file
4
Task/Array-concatenation/Ruby/array-concatenation-2.rb
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
# concat multiple arrays:
|
||||
[arr1,arr2,arr3].flatten(1)
|
||||
# ignore nil:
|
||||
[arr1,arr2,arr3].compact.flatten(1)
|
||||
3
Task/Array-concatenation/SETL/array-concatenation.setl
Normal file
3
Task/Array-concatenation/SETL/array-concatenation.setl
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
A := [1, 2, 3];
|
||||
B := [3, 4, 5];
|
||||
print(A + B); -- [1 2 3 3 4 5]
|
||||
Loading…
Add table
Add a link
Reference in a new issue