task_url stringlengths 30 116 | task_name stringlengths 2 86 | task_description stringlengths 0 14.4k | language_url stringlengths 2 53 | language_name stringlengths 1 52 | code stringlengths 0 61.9k |
|---|---|---|---|---|---|
http://rosettacode.org/wiki/Ascending_primes | Ascending primes | Generate and show all primes with strictly ascending decimal digits.
Aside: Try solving without peeking at existing solutions. I had a weird idea for generating
a prime sieve faster, which needless to say didn't pan out. The solution may be p(r)etty trivial
but generating them quickly is at least mildly interesting.
T... | #ALGOL_68 | ALGOL 68 | BEGIN # find all primes with strictly increasing digits #
PR read "primes.incl.a68" PR # include prime utilities #
PR read "rows.incl.a68" PR # include array utilities #
[ 1 : 512 ]INT primes; # there will be at most 512 (2^9) primes #
... |
http://rosettacode.org/wiki/Ascending_primes | Ascending primes | Generate and show all primes with strictly ascending decimal digits.
Aside: Try solving without peeking at existing solutions. I had a weird idea for generating
a prime sieve faster, which needless to say didn't pan out. The solution may be p(r)etty trivial
but generating them quickly is at least mildly interesting.
T... | #Arturo | Arturo | ascending?: function [x][
initial: digits x
and? [equal? sort initial initial][equal? size initial size unique initial]
]
candidates: select (1..1456789) ++ [
12345678, 12345679, 12345689, 12345789, 12346789,
12356789, 12456789, 13456789, 23456789, 123456789
] => prime?
ascendingNums: select candid... |
http://rosettacode.org/wiki/Ascending_primes | Ascending primes | Generate and show all primes with strictly ascending decimal digits.
Aside: Try solving without peeking at existing solutions. I had a weird idea for generating
a prime sieve faster, which needless to say didn't pan out. The solution may be p(r)etty trivial
but generating them quickly is at least mildly interesting.
T... | #AWK | AWK |
# syntax: GAWK -f ASCENDING_PRIMES.AWK
BEGIN {
start = 1
stop = 23456789
for (i=start; i<=stop; i++) {
if (is_prime(i)) {
primes++
leng = length(i)
flag = 1
for (j=1; j<leng; j++) {
if (substr(i,j,1) >= substr(i,j+1,1)) {
flag = 0
bre... |
http://rosettacode.org/wiki/Ascending_primes | Ascending primes | Generate and show all primes with strictly ascending decimal digits.
Aside: Try solving without peeking at existing solutions. I had a weird idea for generating
a prime sieve faster, which needless to say didn't pan out. The solution may be p(r)etty trivial
but generating them quickly is at least mildly interesting.
T... | #F.23 | F# |
// Ascending primes. Nigel Galloway: April 19th., 2022
[2;3;5;7]::List.unfold(fun(n,i)->match n with []->None |_->let n=n|>List.map(fun(n,g)->[for n in n.. -1..1->(n-1,i*n+g)])|>List.concat in Some(n|>List.choose(fun(_,n)->if isPrime n then Some n else None),(n|>List.filter(fst>>(<)0),i*10)))([(2,3);(6,7);(8,9)],10)
... |
http://rosettacode.org/wiki/Ascending_primes | Ascending primes | Generate and show all primes with strictly ascending decimal digits.
Aside: Try solving without peeking at existing solutions. I had a weird idea for generating
a prime sieve faster, which needless to say didn't pan out. The solution may be p(r)etty trivial
but generating them quickly is at least mildly interesting.
T... | #Factor | Factor | USING: grouping math math.combinatorics math.functions
math.primes math.ranges prettyprint sequences sequences.extras ;
9 [1,b] all-subsets [ reverse 0 [ 10^ * + ] reduce-index ]
[ prime? ] map-filter 10 group simple-table. |
http://rosettacode.org/wiki/Ascending_primes | Ascending primes | Generate and show all primes with strictly ascending decimal digits.
Aside: Try solving without peeking at existing solutions. I had a weird idea for generating
a prime sieve faster, which needless to say didn't pan out. The solution may be p(r)etty trivial
but generating them quickly is at least mildly interesting.
T... | #Go | Go | package main
import (
"fmt"
"rcu"
"sort"
)
var ascPrimesSet = make(map[int]bool) // avoids duplicates
func generate(first, cand, digits int) {
if digits == 0 {
if rcu.IsPrime(cand) {
ascPrimesSet[cand] = true
}
return
}
for i := first; i < 10; i++ {
... |
http://rosettacode.org/wiki/Ascending_primes | Ascending primes | Generate and show all primes with strictly ascending decimal digits.
Aside: Try solving without peeking at existing solutions. I had a weird idea for generating
a prime sieve faster, which needless to say didn't pan out. The solution may be p(r)etty trivial
but generating them quickly is at least mildly interesting.
T... | #J | J | extend=: {{ y;(1+each i._1+{.y),L:0 y }}
$(#~ 1 p: ])10#.&>([:~.@;extend each)^:# >:i.9
100
10 10$(#~ 1 p: ])10#.&>([:~.@;extend each)^:# >:i.9
2 3 13 23 5 7 17 37 47 67
127 137 347 157 257 457 167 367 467 1237
2347 23... |
http://rosettacode.org/wiki/Ascending_primes | Ascending primes | Generate and show all primes with strictly ascending decimal digits.
Aside: Try solving without peeking at existing solutions. I had a weird idea for generating
a prime sieve faster, which needless to say didn't pan out. The solution may be p(r)etty trivial
but generating them quickly is at least mildly interesting.
T... | #jq | jq |
# Output: the stream of ascending primes, in order
def ascendingPrimes:
# Generate the stream of primes beginning with the digit .
# and with strictly ascending digits, without regard to order
def generate:
# strings
def g:
. as $first
| tonumber as $n
| select($n <= 9)
| $first,... |
http://rosettacode.org/wiki/Ascending_primes | Ascending primes | Generate and show all primes with strictly ascending decimal digits.
Aside: Try solving without peeking at existing solutions. I had a weird idea for generating
a prime sieve faster, which needless to say didn't pan out. The solution may be p(r)etty trivial
but generating them quickly is at least mildly interesting.
T... | #Julia | Julia | using Combinatorics
using Primes
function ascendingprimes()
return filter(isprime, [evalpoly(10, reverse(x))
for x in powerset([1, 2, 3, 4, 5, 6, 7, 8, 9]) if !isempty(x)])
end
foreach(p -> print(rpad(p[2], 10), p[1] % 10 == 0 ? "\n" : ""), enumerate(ascendingprimes()))
@time ascendingprimes()
|
http://rosettacode.org/wiki/Ascending_primes | Ascending primes | Generate and show all primes with strictly ascending decimal digits.
Aside: Try solving without peeking at existing solutions. I had a weird idea for generating
a prime sieve faster, which needless to say didn't pan out. The solution may be p(r)etty trivial
but generating them quickly is at least mildly interesting.
T... | #Lua | Lua | local function is_prime(n)
if n < 2 then return false end
if n % 2 == 0 then return n==2 end
if n % 3 == 0 then return n==3 end
for f = 5, n^0.5, 6 do
if n%f==0 or n%(f+2)==0 then return false end
end
return true
end
local function ascending_primes()
local digits, candidates, primes = {1,2,3,4,5,6,7... |
http://rosettacode.org/wiki/Ascending_primes | Ascending primes | Generate and show all primes with strictly ascending decimal digits.
Aside: Try solving without peeking at existing solutions. I had a weird idea for generating
a prime sieve faster, which needless to say didn't pan out. The solution may be p(r)etty trivial
but generating them quickly is at least mildly interesting.
T... | #Mathematica.2FWolfram_Language | Mathematica/Wolfram Language | ps=Sort@Select[FromDigits /@ Subsets[Range@9, {1, \[Infinity]}], PrimeQ];
Multicolumn[ps, {Automatic, 6}, Appearance -> "Horizontal"] |
http://rosettacode.org/wiki/Ascending_primes | Ascending primes | Generate and show all primes with strictly ascending decimal digits.
Aside: Try solving without peeking at existing solutions. I had a weird idea for generating
a prime sieve faster, which needless to say didn't pan out. The solution may be p(r)etty trivial
but generating them quickly is at least mildly interesting.
T... | #Perl | Perl | #!/usr/bin/perl
use strict; # https://rosettacode.org/wiki/Ascending_primes
use warnings;
use ntheory qw( is_prime );
print join('', map { sprintf "%10d", $_ } sort { $a <=> $b }
grep /./ && is_prime($_),
glob join '', map "{$_,}", 1 .. 9) =~ s/.{50}\K/\n/gr; |
http://rosettacode.org/wiki/Ascending_primes | Ascending primes | Generate and show all primes with strictly ascending decimal digits.
Aside: Try solving without peeking at existing solutions. I had a weird idea for generating
a prime sieve faster, which needless to say didn't pan out. The solution may be p(r)etty trivial
but generating them quickly is at least mildly interesting.
T... | #Phix | Phix | with javascript_semantics
function ascending_primes(sequence res, atom p=0)
for d=remainder(p,10)+1 to 9 do
integer np = p*10+d
if odd(d) and is_prime(np) then res &= np end if
res = ascending_primes(res,np)
end for
return res
end function
sequence r = apply(true,sprintf,{{"%8d"},s... |
http://rosettacode.org/wiki/Ascending_primes | Ascending primes | Generate and show all primes with strictly ascending decimal digits.
Aside: Try solving without peeking at existing solutions. I had a weird idea for generating
a prime sieve faster, which needless to say didn't pan out. The solution may be p(r)etty trivial
but generating them quickly is at least mildly interesting.
T... | #Picat | Picat | import util.
main =>
DP = [N : S in power_set("123456789"), S != [], N = S.to_int, prime(N)].sort,
foreach({P,I} in zip(DP,1..DP.len))
printf("%9d%s",P,cond(I mod 10 == 0,"\n",""))
end,
nl,
println(len=DP.len) |
http://rosettacode.org/wiki/Ascending_primes | Ascending primes | Generate and show all primes with strictly ascending decimal digits.
Aside: Try solving without peeking at existing solutions. I had a weird idea for generating
a prime sieve faster, which needless to say didn't pan out. The solution may be p(r)etty trivial
but generating them quickly is at least mildly interesting.
T... | #Python | Python | from sympy import isprime
def ascending(x=0):
for y in range(x*10 + (x%10) + 1, x*10 + 10):
yield from ascending(y)
yield(y)
print(sorted(x for x in ascending() if isprime(x))) |
http://rosettacode.org/wiki/Ascending_primes | Ascending primes | Generate and show all primes with strictly ascending decimal digits.
Aside: Try solving without peeking at existing solutions. I had a weird idea for generating
a prime sieve faster, which needless to say didn't pan out. The solution may be p(r)etty trivial
but generating them quickly is at least mildly interesting.
T... | #Quackery | Quackery | [ 0 swap witheach
[ swap 10 * + ] ] is digits->n ( [ --> n )
[]
' [ 1 2 3 4 5 6 7 8 9 ] powerset
witheach
[ digits->n dup isprime
iff join else drop ]
sort echo |
http://rosettacode.org/wiki/Ascending_primes | Ascending primes | Generate and show all primes with strictly ascending decimal digits.
Aside: Try solving without peeking at existing solutions. I had a weird idea for generating
a prime sieve faster, which needless to say didn't pan out. The solution may be p(r)etty trivial
but generating them quickly is at least mildly interesting.
T... | #Raku | Raku | put (flat 2, 3, 5, 7, sort +*, gather (1..8).map: &recurse ).batch(10)».fmt("%8d").join: "\n";
sub recurse ($str) {
.take for ($str X~ (3, 7, 9)).grep: { .is-prime && [<] .comb };
recurse $str × 10 + $_ for $str % 10 ^.. 9;
}
printf "%.3f seconds", now - INIT now; |
http://rosettacode.org/wiki/Ascending_primes | Ascending primes | Generate and show all primes with strictly ascending decimal digits.
Aside: Try solving without peeking at existing solutions. I had a weird idea for generating
a prime sieve faster, which needless to say didn't pan out. The solution may be p(r)etty trivial
but generating them quickly is at least mildly interesting.
T... | #Ring | Ring |
load "stdlibcore.ring"
limit = 1000
row = 0
for n = 1 to limit
flag = 0
strn = string(n)
if isprime(n) = 1
for m = 1 to len(strn)-1
if number(substr(strn,m)) > number(substr(strn,m+1))
flag = 1
ok
next
if flag = 1
row++
see "... |
http://rosettacode.org/wiki/Ascending_primes | Ascending primes | Generate and show all primes with strictly ascending decimal digits.
Aside: Try solving without peeking at existing solutions. I had a weird idea for generating
a prime sieve faster, which needless to say didn't pan out. The solution may be p(r)etty trivial
but generating them quickly is at least mildly interesting.
T... | #Sidef | Sidef | func primes_with_ascending_digits(base = 10) {
var list = []
var digits = @(1..^base -> flip)
var end_digits = digits.grep { .is_coprime(base) }
list << digits.grep { .is_prime && !.is_coprime(base) }...
for k in (0 .. digits.end) {
digits.combinations(k, {|*a|
var v = a.di... |
http://rosettacode.org/wiki/Ascending_primes | Ascending primes | Generate and show all primes with strictly ascending decimal digits.
Aside: Try solving without peeking at existing solutions. I had a weird idea for generating
a prime sieve faster, which needless to say didn't pan out. The solution may be p(r)etty trivial
but generating them quickly is at least mildly interesting.
T... | #Vlang | Vlang | fn is_prime(n int) bool {
if n < 2 {
return false
} else if n%2 == 0 {
return n == 2
} else if n%3 == 0 {
return n == 3
} else {
mut d := 5
for d*d <= n {
if n%d == 0 {
return false
}
d += 2
if n%d ==... |
http://rosettacode.org/wiki/Ascending_primes | Ascending primes | Generate and show all primes with strictly ascending decimal digits.
Aside: Try solving without peeking at existing solutions. I had a weird idea for generating
a prime sieve faster, which needless to say didn't pan out. The solution may be p(r)etty trivial
but generating them quickly is at least mildly interesting.
T... | #Wren | Wren | import "./math" for Int
import "./seq" for Lst
import "./fmt" for Fmt
var isAscending = Fn.new { |n|
if (n < 10) return true
var digits = Int.digits(n)
for (i in 1...digits.count) {
if (digits[i] <= digits[i-1]) return false
}
return true
}
var higherPrimes = []
var candidates = [
... |
http://rosettacode.org/wiki/Ascending_primes | Ascending primes | Generate and show all primes with strictly ascending decimal digits.
Aside: Try solving without peeking at existing solutions. I had a weird idea for generating
a prime sieve faster, which needless to say didn't pan out. The solution may be p(r)etty trivial
but generating them quickly is at least mildly interesting.
T... | #XPL0 | XPL0 | func IsPrime(N); \Return 'true' if N is prime
int N, I;
[if N <= 2 then return N = 2;
if (N&1) = 0 then \even >2\ return false;
for I:= 3 to sqrt(N) do
[if rem(N/I) = 0 then return false;
I:= I+1;
];
return true;
];
func Ascending(N); \Return 'true' if digits are ascending
int N, D;
[N:= N/1... |
http://rosettacode.org/wiki/Array_concatenation | Array concatenation | Task
Show how to concatenate two arrays in your language.
If this is as simple as array1 + array2, so be it.
| #11l | 11l | V arr1 = [1, 2, 3]
V arr2 = [4, 5, 6]
print(arr1 [+] arr2) |
http://rosettacode.org/wiki/Array_concatenation | Array concatenation | Task
Show how to concatenate two arrays in your language.
If this is as simple as array1 + array2, so be it.
| #68000_Assembly | 68000 Assembly | ArrayRam equ $00FF2000 ;this label points to 4k of free space.
;concatenate Array1 + Array2
LEA ArrayRam,A0
LEA Array1,A1
MOVE.W #5-1,D1 ;LEN(Array1), measured in words.
JSR memcpy_w
;after this, A0 will point to the destination of the second array.
LEA Array2,A1 ;even though the source arrays are stored back... |
http://rosettacode.org/wiki/Array_concatenation | Array concatenation | Task
Show how to concatenate two arrays in your language.
If this is as simple as array1 + array2, so be it.
| #8th | 8th |
[1,2,3] [4,5,6] a:+ .
|
http://rosettacode.org/wiki/Array_concatenation | Array concatenation | Task
Show how to concatenate two arrays in your language.
If this is as simple as array1 + array2, so be it.
| #AArch64_Assembly | AArch64 Assembly |
/* ARM assembly AARCH64 Raspberry PI 3B */
/* program concAreaString.s */
/*******************************************/
/* Constantes file */
/*******************************************/
/* for this file see task include a file in language AArch64 assembly*/
.include "../includeConstante... |
http://rosettacode.org/wiki/Array_concatenation | Array concatenation | Task
Show how to concatenate two arrays in your language.
If this is as simple as array1 + array2, so be it.
| #ABAP | ABAP |
report z_array_concatenation.
data(itab1) = value int4_table( ( 1 ) ( 2 ) ( 3 ) ).
data(itab2) = value int4_table( ( 4 ) ( 5 ) ( 6 ) ).
append lines of itab2 to itab1.
loop at itab1 assigning field-symbol(<line>).
write <line>.
endloop.
|
http://rosettacode.org/wiki/Array_concatenation | Array concatenation | Task
Show how to concatenate two arrays in your language.
If this is as simple as array1 + array2, so be it.
| #ACL2 | ACL2 | (append xs ys) |
http://rosettacode.org/wiki/Array_concatenation | Array concatenation | Task
Show how to concatenate two arrays in your language.
If this is as simple as array1 + array2, so be it.
| #Action.21 | Action! | BYTE FUNC Concat(INT ARRAY src1,src2,dst BYTE size1,size2)
BYTE i
FOR i=0 TO size1-1
DO
dst(i)=src1(i)
OD
FOR i=0 TO size2-1
DO
dst(size1+i)=src2(i)
OD
RETURN (size1+size2)
PROC PrintArray(INT ARRAY a BYTE size)
BYTE i
Put('[)
FOR i=0 TO size-1
DO
PrintI(a(i))
IF i<size-1 THE... |
http://rosettacode.org/wiki/Array_concatenation | Array concatenation | Task
Show how to concatenate two arrays in your language.
If this is as simple as array1 + array2, so be it.
| #ActionScript | ActionScript | var array1:Array = new Array(1, 2, 3);
var array2:Array = new Array(4, 5, 6);
var array3:Array = array1.concat(array2); //[1, 2, 3, 4, 5, 6] |
http://rosettacode.org/wiki/Array_concatenation | Array concatenation | Task
Show how to concatenate two arrays in your language.
If this is as simple as array1 + array2, so be it.
| #Ada | Ada | type T is array (Positive range <>) of Integer;
X : T := (1, 2, 3);
Y : T := X & (4, 5, 6); -- Concatenate X and (4, 5, 6) |
http://rosettacode.org/wiki/Array_concatenation | Array concatenation | Task
Show how to concatenate two arrays in your language.
If this is as simple as array1 + array2, so be it.
| #Aime | Aime | ac(list a, b)
{
list o;
o.copy(a);
b.ucall(l_append, 1, o);
o;
}
main(void)
{
list a, b, c;
a = list(1, 2, 3, 4);
b = list(5, 6, 7, 8);
c = ac(a, b);
c.ucall(o_, 1, " ");
0;
} |
http://rosettacode.org/wiki/Array_concatenation | Array concatenation | Task
Show how to concatenate two arrays in your language.
If this is as simple as array1 + array2, so be it.
| #ALGOL_68 | ALGOL 68 | MODE ARGTYPE = INT;
MODE ARGLIST = FLEX[0]ARGTYPE;
OP + = (ARGLIST a, b)ARGLIST: (
[LWB a:UPB a - LWB a + 1 + UPB b - LWB b + 1 ]ARGTYPE out;
(
out[LWB a:UPB a]:=a,
out[UPB a+1:]:=b
);
out
);
# Append #
OP +:= = (REF ARGLIST lhs, ARGLIST rhs)ARGLIST: lhs := lhs + rhs;
OP PLUSAB = (REF ARGLIST lh... |
http://rosettacode.org/wiki/Array_concatenation | Array concatenation | Task
Show how to concatenate two arrays in your language.
If this is as simple as array1 + array2, so be it.
| #ALGOL_W | ALGOL W | begin
integer array a ( 1 :: 5 );
integer array b ( 2 :: 4 );
integer array c ( 1 :: 8 );
% concatenates the arrays a and b into c %
% the lower and upper bounds of each array must be specified in %
% the corresponding *Lb and *Ub parameters %
pr... |
http://rosettacode.org/wiki/Array_concatenation | Array concatenation | Task
Show how to concatenate two arrays in your language.
If this is as simple as array1 + array2, so be it.
| #Amazing_Hopper | Amazing Hopper |
#include <hbasic.h>
Begin
a1 = {}
a2 = {}
Take(100,"Hola",0.056,"Mundo!"), and Push All(a1)
Take("Segundo",0,"array",~True,~False), and Push All(a2)
Concat (a1, a2) and Print ( a2, Newl )
End
|
http://rosettacode.org/wiki/Array_concatenation | Array concatenation | Task
Show how to concatenate two arrays in your language.
If this is as simple as array1 + array2, so be it.
| #AntLang | AntLang | a:<1; <2; 3>>
b: <"Hello"; 42>
c: a,b |
http://rosettacode.org/wiki/Array_concatenation | Array concatenation | Task
Show how to concatenate two arrays in your language.
If this is as simple as array1 + array2, so be it.
| #Apex | Apex | List<String> listA = new List<String> { 'apple' };
List<String> listB = new List<String> { 'banana' };
listA.addAll(listB);
System.debug(listA); // Prints (apple, banana) |
http://rosettacode.org/wiki/Array_concatenation | Array concatenation | Task
Show how to concatenate two arrays in your language.
If this is as simple as array1 + array2, so be it.
| #APL | APL |
1 2 3 , 4 5 6
1 2 3 4 5 6
|
http://rosettacode.org/wiki/Array_concatenation | Array concatenation | Task
Show how to concatenate two arrays in your language.
If this is as simple as array1 + array2, so be it.
| #AppleScript | AppleScript |
set listA to {1, 2, 3}
set listB to {4, 5, 6}
return listA & listB
|
http://rosettacode.org/wiki/Array_concatenation | Array concatenation | Task
Show how to concatenate two arrays in your language.
If this is as simple as array1 + array2, so be it.
| #ARM_Assembly | ARM Assembly |
/* ARM assembly Raspberry PI */
/* program concAreaString.s */
/* Constantes */
.equ STDOUT, 1 @ Linux output console
.equ EXIT, 1 @ Linux syscall
.equ WRITE, 4 @ Linux syscall
.equ NBMAXITEMS, 20 @
/* Initialized data */
.data
szMessLenArea: .ascii "The length of area 3 is : "
sZoneconv:... |
http://rosettacode.org/wiki/Array_concatenation | Array concatenation | Task
Show how to concatenate two arrays in your language.
If this is as simple as array1 + array2, so be it.
| #Arturo | Arturo | arr1: [1 2 3]
arr2: ["four" "five" "six"]
print arr1 ++ arr2 |
http://rosettacode.org/wiki/Array_concatenation | Array concatenation | Task
Show how to concatenate two arrays in your language.
If this is as simple as array1 + array2, so be it.
| #ATS | ATS | (* The Rosetta Code array concatenation task, in ATS2. *)
(* In a way, the task is misleading: in a language such as ATS, one
can always devise a very-easy-to-use array type, put the code for
that in a library, and overload operators. Thus we can have
"array1 + array2" as array concatenation in ATS, complete... |
http://rosettacode.org/wiki/Array_concatenation | Array concatenation | Task
Show how to concatenate two arrays in your language.
If this is as simple as array1 + array2, so be it.
| #AutoHotkey | AutoHotkey | List1 := [1, 2, 3]
List2 := [4, 5, 6]
cList := Arr_concatenate(List1, List2)
MsgBox % Arr_disp(cList) ; [1, 2, 3, 4, 5, 6]
Arr_concatenate(p*) {
res := Object()
For each, obj in p
For each, value in obj
res.Insert(value)
return res
}
Arr_disp(arr) {
for each, value in arr
... |
http://rosettacode.org/wiki/Array_concatenation | Array concatenation | Task
Show how to concatenate two arrays in your language.
If this is as simple as array1 + array2, so be it.
| #AutoIt | AutoIt |
_ArrayConcatenate($avArray, $avArray2)
Func _ArrayConcatenate(ByRef $avArrayTarget, Const ByRef $avArraySource, $iStart = 0)
If Not IsArray($avArrayTarget) Then Return SetError(1, 0, 0)
If Not IsArray($avArraySource) Then Return SetError(2, 0, 0)
If UBound($avArrayTarget, 0) <> 1 Then
If UBound($avArraySource, 0... |
http://rosettacode.org/wiki/Array_concatenation | Array concatenation | Task
Show how to concatenate two arrays in your language.
If this is as simple as array1 + array2, so be it.
| #Avail | Avail | <1, 2, 3> ++ <¢a, ¢b, ¢c> |
http://rosettacode.org/wiki/Array_concatenation | Array concatenation | Task
Show how to concatenate two arrays in your language.
If this is as simple as array1 + array2, so be it.
| #AWK | AWK | #!/usr/bin/awk -f
BEGIN {
split("cul-de-sac",a,"-")
split("1-2-3",b,"-")
concat_array(a,b,c)
for (i in c) {
print i,c[i]
}
}
function concat_array(a,b,c, nc) {
for (i in a) {
c[++nc]=a[i]
}
for (i in b) {
c[++nc]=b[i]
}
} |
http://rosettacode.org/wiki/Array_concatenation | Array concatenation | Task
Show how to concatenate two arrays in your language.
If this is as simple as array1 + array2, so be it.
| #Babel | Babel | [1 2 3] [4 5 6] cat ; |
http://rosettacode.org/wiki/Array_concatenation | Array concatenation | Task
Show how to concatenate two arrays in your language.
If this is as simple as array1 + array2, so be it.
| #bash | bash | x=("1 2" "3 4")
y=(5 6)
sum=( "${x[@]}" "${y[@]}" )
for i in "${sum[@]}" ; do echo "$i" ; done
1 2
3 4
5
6 |
http://rosettacode.org/wiki/Array_concatenation | Array concatenation | Task
Show how to concatenate two arrays in your language.
If this is as simple as array1 + array2, so be it.
| #BASIC | BASIC | DECLARE a[] = { 1, 2, 3, 4, 5 }
DECLARE b[] = { 6, 7, 8, 9, 10 }
DECLARE c ARRAY UBOUND(a) + UBOUND(b)
FOR x = 0 TO 4
c[x] = a[x]
c[x+5] = b[x]
NEXT |
http://rosettacode.org/wiki/Array_concatenation | Array concatenation | Task
Show how to concatenate two arrays in your language.
If this is as simple as array1 + array2, so be it.
| #BASIC256 | BASIC256 | arraybase 1
global c
dimen = 5
dim a(dimen)
dim b(dimen)
# Array initialization
for i = 1 to dimen
a[i] = i
b[i] = i + dimen
next i
nt = ConcatArrays(a, b)
for i = 1 to nt
print c[i];
if i < nt then print ", ";
next i
end
function ConcatArrays(a, b)
ta = a[?]
tb = b[?]
nt = ta + tb
redim c(nt)
for ... |
http://rosettacode.org/wiki/Array_concatenation | Array concatenation | Task
Show how to concatenate two arrays in your language.
If this is as simple as array1 + array2, so be it.
| #BQN | BQN | 1‿2‿3 ∾ 4‿5‿6 |
http://rosettacode.org/wiki/Array_concatenation | Array concatenation | Task
Show how to concatenate two arrays in your language.
If this is as simple as array1 + array2, so be it.
| #Bracmat | Bracmat | {?} (a,b,c,d,e),(n,m)
{!} a,b,c,d,e,n,m
{?} (a,m,y),(b,n,y,z)
{!} a,m,y,b,n,y,z
{?} (a m y) (b n y z)
{!} a m y b n y z
{?} (a+m+y)+(b+n+y+z)
{!} a+b+m+n+2*y+z
{?} (a*m*y)*(b*n*y*z)
{!} a*b*m*n*y^2*z |
http://rosettacode.org/wiki/Array_concatenation | Array concatenation | Task
Show how to concatenate two arrays in your language.
If this is as simple as array1 + array2, so be it.
| #Burlesque | Burlesque |
blsq ) {1 2 3}{4 5 6}_+
{1 2 3 4 5 6}
|
http://rosettacode.org/wiki/Array_concatenation | Array concatenation | Task
Show how to concatenate two arrays in your language.
If this is as simple as array1 + array2, so be it.
| #C | C | #include <stdlib.h>
#include <stdio.h>
#include <string.h>
#define ARRAY_CONCAT(TYPE, A, An, B, Bn) \
(TYPE *)array_concat((const void *)(A), (An), (const void *)(B), (Bn), sizeof(TYPE));
void *array_concat(const void *a, size_t an,
const void *b, size_t bn, size_t s)
{
char *p = malloc(s * (... |
http://rosettacode.org/wiki/Array_concatenation | Array concatenation | Task
Show how to concatenate two arrays in your language.
If this is as simple as array1 + array2, so be it.
| #C.23 | C# | 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);
forea... |
http://rosettacode.org/wiki/Array_concatenation | Array concatenation | Task
Show how to concatenate two arrays in your language.
If this is as simple as array1 + array2, so be it.
| #C.2B.2B | C++ | #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";
} |
http://rosettacode.org/wiki/Array_concatenation | Array concatenation | Task
Show how to concatenate two arrays in your language.
If this is as simple as array1 + array2, so be it.
| #Ceylon | Ceylon | shared void arrayConcatenation() {
value a = Array {1, 2, 3};
value b = Array {4, 5, 6};
value c = concatenate(a, b);
print(c);
} |
http://rosettacode.org/wiki/Array_concatenation | Array concatenation | Task
Show how to concatenate two arrays in your language.
If this is as simple as array1 + array2, so be it.
| #Clojure | Clojure | (concat [1 2 3] [4 5 6]) |
http://rosettacode.org/wiki/Array_concatenation | Array concatenation | Task
Show how to concatenate two arrays in your language.
If this is as simple as array1 + array2, so be it.
| #COBOL | COBOL | identification division.
program-id. array-concat.
environment division.
configuration section.
repository.
function all intrinsic.
data division.
working-storage section.
01 table-one.
05 int-field pic 999 occurs 0 to 5 depending on t1.
... |
http://rosettacode.org/wiki/Array_concatenation | Array concatenation | Task
Show how to concatenate two arrays in your language.
If this is as simple as array1 + array2, so be it.
| #CoffeeScript | CoffeeScript |
# like in JavaScript
a = [1, 2, 3]
b = [4, 5, 6]
c = a.concat b
|
http://rosettacode.org/wiki/Array_concatenation | Array concatenation | Task
Show how to concatenate two arrays in your language.
If this is as simple as array1 + array2, so be it.
| #Common_Lisp | Common Lisp | (concatenate 'vector #(0 1 2 3) #(4 5 6 7))
=> #(0 1 2 3 4 5 6 7) |
http://rosettacode.org/wiki/Array_concatenation | Array concatenation | Task
Show how to concatenate two arrays in your language.
If this is as simple as array1 + array2, so be it.
| #Component_Pascal | Component Pascal |
MODULE ArrayConcat;
IMPORT StdLog;
PROCEDURE Concat(x: ARRAY OF INTEGER; y: ARRAY OF INTEGER; OUT z: ARRAY OF INTEGER);
VAR
i: INTEGER;
BEGIN
ASSERT(LEN(x) + LEN(y) <= LEN(z));
FOR i := 0 TO LEN(x) - 1 DO z[i] := x[i] END;
FOR i := 0 TO LEN(y) - 1 DO z[i + LEN(x)] := y[i] END
END Concat;
PROCEDURE Concat2(x: ... |
http://rosettacode.org/wiki/Array_concatenation | Array concatenation | Task
Show how to concatenate two arrays in your language.
If this is as simple as array1 + array2, so be it.
| #Crystal | Crystal | arr1 = [1, 2, 3]
arr2 = ["foo", "bar", "baz"]
arr1 + arr2 #=> [1, 2, 3, "foo", "bar", "baz"] |
http://rosettacode.org/wiki/Array_concatenation | Array concatenation | Task
Show how to concatenate two arrays in your language.
If this is as simple as array1 + array2, so be it.
| #D | D | import std.stdio: writeln;
void main() {
int[] a = [1, 2];
int[] b = [4, 5, 6];
writeln(a, " ~ ", b, " = ", a ~ b);
} |
http://rosettacode.org/wiki/Array_concatenation | Array concatenation | Task
Show how to concatenate two arrays in your language.
If this is as simple as array1 + array2, so be it.
| #Delphi | Delphi | 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, j... |
http://rosettacode.org/wiki/Array_concatenation | Array concatenation | Task
Show how to concatenate two arrays in your language.
If this is as simple as array1 + array2, so be it.
| #Dyalect | Dyalect | var xs = [1,2,3]
var ys = [4,5,6]
var alls = Array.Concat(xs, ys)
print(alls) |
http://rosettacode.org/wiki/Array_concatenation | Array concatenation | Task
Show how to concatenate two arrays in your language.
If this is as simple as array1 + array2, so be it.
| #E | E | ? [1,2] + [3,4]
# value: [1, 2, 3, 4] |
http://rosettacode.org/wiki/Array_concatenation | Array concatenation | Task
Show how to concatenate two arrays in your language.
If this is as simple as array1 + array2, so be it.
| #EasyLang | EasyLang | a[] = [ 1 2 3 ]
b[] = [ 4 5 6 ]
c[] = a[]
while i < len b[]
c[] &= b[i]
i += 1
.
print c[] |
http://rosettacode.org/wiki/Array_concatenation | Array concatenation | Task
Show how to concatenate two arrays in your language.
If this is as simple as array1 + array2, so be it.
| #EchoLisp | EchoLisp |
;;;; VECTORS
(vector-append (make-vector 6 42) (make-vector 4 666))
→ #( 42 42 42 42 42 42 666 666 666 666)
;;;; LISTS
(append (iota 5) (iota 6))
→ (0 1 2 3 4 0 1 2 3 4 5)
;; NB - append may also be used with sequences (lazy lists)
(lib 'sequences)
(take (append [1 .. 7] [7 6 .. 0]) #:all)
→ (1 2 3 4... |
http://rosettacode.org/wiki/Array_concatenation | Array concatenation | Task
Show how to concatenate two arrays in your language.
If this is as simple as array1 + array2, so be it.
| #ECL | ECL |
A := [1, 2, 3, 4];
B := [5, 6, 7, 8];
C := A + B; |
http://rosettacode.org/wiki/Array_concatenation | Array concatenation | Task
Show how to concatenate two arrays in your language.
If this is as simple as array1 + array2, so be it.
| #Efene | Efene |
@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])
} |
http://rosettacode.org/wiki/Array_concatenation | Array concatenation | Task
Show how to concatenate two arrays in your language.
If this is as simple as array1 + array2, so be it.
| #EGL | EGL |
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
|
http://rosettacode.org/wiki/Array_concatenation | Array concatenation | Task
Show how to concatenate two arrays in your language.
If this is as simple as array1 + array2, so be it.
| #Ela | Ela | xs = [1,2,3]
ys = [4,5,6]
xs ++ ys |
http://rosettacode.org/wiki/Array_concatenation | Array concatenation | Task
Show how to concatenate two arrays in your language.
If this is as simple as array1 + array2, so be it.
| #Elena | Elena | import extensions;
public program()
{
var a := new int[]{1,2,3};
var b := new int[]{4,5};
console.printLine(
"(",a.asEnumerable(),") + (",b.asEnumerable(),
") = (",(a + b).asEnumerable(),")").readChar();
} |
http://rosettacode.org/wiki/Array_concatenation | Array concatenation | Task
Show how to concatenate two arrays in your language.
If this is as simple as array1 + array2, so be it.
| #Elixir | Elixir | 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] |
http://rosettacode.org/wiki/Array_concatenation | Array concatenation | Task
Show how to concatenate two arrays in your language.
If this is as simple as array1 + array2, so be it.
| #Elm | Elm | import Element exposing (show, toHtml) -- elm-package install evancz/elm-graphics
import Html.App exposing (beginnerProgram)
import Array exposing (Array, append, initialize)
xs : Array Int
xs =
initialize 3 identity -- [0, 1, 2]
ys : Array Int
ys =
initialize 3 <| (+) 3 -- [3, 4, 5]
main = beginnerProgr... |
http://rosettacode.org/wiki/Array_concatenation | Array concatenation | Task
Show how to concatenate two arrays in your language.
If this is as simple as array1 + array2, so be it.
| #Emacs_Lisp | Emacs Lisp | (vconcat '[1 2 3] '[4 5] '[6 7 8 9])
=> [1 2 3 4 5 6 7 8 9] |
http://rosettacode.org/wiki/Array_concatenation | Array concatenation | Task
Show how to concatenate two arrays in your language.
If this is as simple as array1 + array2, so be it.
| #Erlang | Erlang |
1> [1, 2, 3] ++ [4, 5, 6].
[1,2,3,4,5,6]
2> lists:append([1, 2, 3], [4, 5, 6]).
[1,2,3,4,5,6]
3>
|
http://rosettacode.org/wiki/Array_concatenation | Array concatenation | Task
Show how to concatenate two arrays in your language.
If this is as simple as array1 + array2, so be it.
| #ERRE | ERRE |
PROGRAM ARRAY_CONCAT
DIM A[5],B[5],C[10]
!
! for rosettacode.org
!
BEGIN
DATA(1,2,3,4,5)
DATA(6,7,8,9,0)
FOR I=1 TO 5 DO ! read array A[.]
READ(A[I])
END FOR
FOR I=1 TO 5 DO ! read array B[.]
READ(B[I])
END FOR
FOR I=1 TO 10 DO ! append B[.] to A[.]
IF I>5 THEN
C[I]=B[I-5]... |
http://rosettacode.org/wiki/Array_concatenation | Array concatenation | Task
Show how to concatenate two arrays in your language.
If this is as simple as array1 + array2, so be it.
| #Euphoria | Euphoria | sequence s1,s2,s3
s1 = {1,2,3}
s2 = {4,5,6}
s3 = s1 & s2
? s3 |
http://rosettacode.org/wiki/Array_concatenation | Array concatenation | Task
Show how to concatenate two arrays in your language.
If this is as simple as array1 + array2, so be it.
| #F.23 | F# | let a = [|1; 2; 3|]
let b = [|4; 5; 6;|]
let c = Array.append a b |
http://rosettacode.org/wiki/Array_concatenation | Array concatenation | Task
Show how to concatenate two arrays in your language.
If this is as simple as array1 + array2, so be it.
| #Factor | Factor | append |
http://rosettacode.org/wiki/Array_concatenation | Array concatenation | Task
Show how to concatenate two arrays in your language.
If this is as simple as array1 + array2, so be it.
| #Fantom | Fantom |
> a := [1,2,3]
> b := [4,5,6]
> a.addAll(b)
> a
[1,2,3,4,5,6]
|
http://rosettacode.org/wiki/Array_concatenation | Array concatenation | Task
Show how to concatenate two arrays in your language.
If this is as simple as array1 + array2, so be it.
| #FBSL | FBSL | #APPTYPE CONSOLE
DIM aint[] ={1, 2, 3}, astr[] ={"one", "two", "three"}, asng[] ={!1, !2, !3}
FOREACH DIM e IN ARRAYMERGE(aint, astr, asng)
PRINT e, " ";
NEXT
PAUSE |
http://rosettacode.org/wiki/Array_concatenation | Array concatenation | Task
Show how to concatenate two arrays in your language.
If this is as simple as array1 + array2, so be it.
| #Forth | Forth | : $!+ ( a u a' -- a'+u )
2dup + >r swap move r> ;
: cat ( a2 u2 a1 u1 -- a3 u1+u2 )
align here dup >r $!+ $!+ r> tuck - dup allot ;
\ TEST
create a1 1 , 2 , 3 ,
create a2 4 , 5 ,
a2 2 cells a1 3 cells cat dump
8018425F0: 01 00 00 00 00 00 00 00 - 02 00 00 00 00 00 00 00 ................
801842600: 03 0... |
http://rosettacode.org/wiki/Array_concatenation | Array concatenation | Task
Show how to concatenate two arrays in your language.
If this is as simple as array1 + array2, so be it.
| #Fortran | Fortran | program Concat_Arrays
implicit none
! Note: in Fortran 90 you must use the old array delimiters (/ , /)
integer, dimension(3) :: a = [1, 2, 3] ! (/1, 2, 3/)
integer, dimension(3) :: b = [4, 5, 6] ! (/4, 5, 6/)
integer, dimension(:), allocatable :: c, d
allocate(c(size(a)+size(b)))
c(1 : size(a)) = a
... |
http://rosettacode.org/wiki/Array_concatenation | Array concatenation | Task
Show how to concatenate two arrays in your language.
If this is as simple as array1 + array2, so be it.
| #Free_Pascal | Free Pascal | array2 := array0 + array1 |
http://rosettacode.org/wiki/Array_concatenation | Array concatenation | Task
Show how to concatenate two arrays in your language.
If this is as simple as array1 + array2, so be it.
| #FreeBASIC | FreeBASIC |
' FB 1.05.0 Win64
Sub ConcatArrays(a() As String, b() As String, c() As String)
Dim aSize As Integer = UBound(a) - LBound(a) + 1
Dim bSize As Integer = UBound(b) - LBound(b) + 1
Dim cSize As Integer = aSize + bSize
Redim c(0 To cSize - 1)
Dim i As Integer
For i = 0 To aSize - 1
c(i) = a(LBoun... |
http://rosettacode.org/wiki/Array_concatenation | Array concatenation | Task
Show how to concatenate two arrays in your language.
If this is as simple as array1 + array2, so be it.
| #Frink | Frink |
a = [1,2]
b = [3,4]
a.pushAll[b]
|
http://rosettacode.org/wiki/Array_concatenation | Array concatenation | Task
Show how to concatenate two arrays in your language.
If this is as simple as array1 + array2, so be it.
| #FunL | FunL | arr1 = array( [1, 2, 3] )
arr2 = array( [4, 5, 6] )
arr3 = array( [7, 8, 9] )
println( arr1 + arr2 + arr3 ) |
http://rosettacode.org/wiki/Array_concatenation | Array concatenation | Task
Show how to concatenate two arrays in your language.
If this is as simple as array1 + array2, so be it.
| #Futhark | Futhark |
concat as bs cd
|
http://rosettacode.org/wiki/Array_concatenation | Array concatenation | Task
Show how to concatenate two arrays in your language.
If this is as simple as array1 + array2, so be it.
| #FutureBasic | FutureBasic | void local fn DoIt
CFArrayRef array = @[@"Alpha",@"Bravo",@"Charlie"]
print array
array = fn ArrayByAddingObjectsFromArray( array, @[@"Delta",@"Echo",@"FutureBasic"] )
print array
end fn
window 1
fn DoIt
HandleEvents |
http://rosettacode.org/wiki/Array_concatenation | Array concatenation | Task
Show how to concatenate two arrays in your language.
If this is as simple as array1 + array2, so be it.
| #Gambas | Gambas | Public Sub Main()
Dim sString1 As String[] = ["The", "quick", "brown", "fox"]
Dim sString2 As String[] = ["jumped", "over", "the", "lazy", "dog"]
sString1.Insert(sString2)
Print sString1.Join(" ")
End |
http://rosettacode.org/wiki/Array_concatenation | Array concatenation | Task
Show how to concatenate two arrays in your language.
If this is as simple as array1 + array2, so be it.
| #GAP | GAP | # Concatenate arrays
Concatenation([1, 2, 3], [4, 5, 6], [7, 8, 9]);
# [ 1, 2, 3, 4, 5, 6, 7, 8, 9 ]
# Append to a variable
a := [1, 2, 3];
Append(a, [4, 5, 6);
Append(a, [7, 8, 9]);
a;
# [ 1, 2, 3, 4, 5, 6, 7, 8, 9 ] |
http://rosettacode.org/wiki/Array_concatenation | Array concatenation | Task
Show how to concatenate two arrays in your language.
If this is as simple as array1 + array2, so be it.
| #Genie | Genie | [indent=4]
/*
Array concatenation, in Genie
Tectonics: valac array-concat.gs
*/
/* Creates a new array */
def int_array_concat(x:array of int, y:array of int):array of int
var a = new Array of int(false, true, 0) /* (zero-terminated, clear, size) */
a.append_vals (x, x.length)
a.append_vals (y, y.l... |
http://rosettacode.org/wiki/Array_concatenation | Array concatenation | Task
Show how to concatenate two arrays in your language.
If this is as simple as array1 + array2, so be it.
| #GLSL | GLSL |
#define array_concat(T,a1,a2,returned) \
T[a1.length()+a2.length()] returned; \
{ \
for(int i = 0; i < a1.length(); i++){ \
returned[i] = a1[i]; \
} \
for(int i = 0; i < a2.length(); i++){ \
returned[i+a1.length()] = a2[i]; \
} \
}
|
http://rosettacode.org/wiki/Array_concatenation | Array concatenation | Task
Show how to concatenate two arrays in your language.
If this is as simple as array1 + array2, so be it.
| #Go | Go | package main
import "fmt"
func main() {
// Example 1: Idiomatic in Go is use of the append function.
// Elements must be of identical type.
a := []int{1, 2, 3}
b := []int{7, 12, 60} // these are technically slices, not arrays
c := append(a, b...)
fmt.Println(c)
// Example 2: Polymorp... |
http://rosettacode.org/wiki/Array_concatenation | Array concatenation | Task
Show how to concatenate two arrays in your language.
If this is as simple as array1 + array2, so be it.
| #Gosu | Gosu |
var listA = { 1, 2, 3 }
var listB = { 4, 5, 6 }
var listC = listA.concat( listB )
print( listC ) // prints [1, 2, 3, 4, 5, 6]
|
http://rosettacode.org/wiki/Array_concatenation | Array concatenation | Task
Show how to concatenate two arrays in your language.
If this is as simple as array1 + array2, so be it.
| #Groovy | Groovy | def list = [1, 2, 3] + ["Crosby", "Stills", "Nash", "Young"] |
http://rosettacode.org/wiki/Array_concatenation | Array concatenation | Task
Show how to concatenate two arrays in your language.
If this is as simple as array1 + array2, so be it.
| #Haskell | Haskell | (++) :: [a] -> [a] -> [a] |
Subsets and Splits
Select Specific Languages Codes
Retrieves specific programming language names and codes from training data, providing basic filtering but limited analytical value beyond identifying these particular languages.