Append numbers at same position in strings: Difference between revisions

m
Automated syntax highlighting fixup (second round - minor fixes)
m (→‎{{header|Raku}}: Updated for changed task requirements. Add some other similar manipulations.)
m (Automated syntax highlighting fixup (second round - minor fixes))
Line 11:
 
=={{header|11l}}==
<syntaxhighlight lang="11l">V list1 = [1, 2, 3, 4, 5, 6, 7, 8, 9]
V list2 = [10, 11, 12, 13, 14, 15, 16, 17, 18]
V list3 = [19, 20, 21, 22, 23, 24, 25, 26, 27]
Line 23:
 
=={{header|Ada}}==
<syntaxhighlight lang=Ada"ada">with Ada.Text_Io;
with Ada.Strings.Fixed;
 
Line 61:
 
=={{header|ALGOL 68}}==
<syntaxhighlight lang="algol68">BEGIN # form a list of strings by concatenating numbers from 3 lists #
[]INT list1 = ( 1, 2, 3, 4, 5, 6, 7, 8, 9 )
, list2 = ( 10, 11, 12, 13, 14, 15, 16, 17, 18 )
Line 84:
=={{header|APL}}==
{{works with|Dyalog APL}}
<syntaxhighlight lang="apl">list1←1 2 3 4 5 6 7 8 9
list2←10 11 12 13 14 15 16 17 18
list3←19 20 21 22 23 24 25 26 27
Line 93:
 
=={{header|AutoHotkey}}==
<syntaxhighlight lang=AutoHotkey"autohotkey">list1 := [1,2,3,4,5,6,7,8,9]
list2 := [10,11,12,13,14,15,16,17,18]
list3 := [19,20,21,22,23,24,25,26,27]
Line 107:
 
=={{header|AWK}}==
<syntaxhighlight lang=AWK"awk">
# syntax: GAWK -f APPEND_NUMBERS_AT_SAME_POSITION_IN_STRINGS.AWK
BEGIN {
Line 131:
 
=={{header|C}}==
<syntaxhighlight lang="c">#include<stdio.h>
#include<stdlib.h>
 
Line 143:
 
=={{header|CLU}}==
<syntaxhighlight lang="clu">append = proc (lists: sequence[sequence[int]]) returns (sequence[int])
n_lists: int := sequence[sequence[int]]$size(lists)
n_items: int := sequence[int]$size(lists[1])
Line 171:
 
=={{header|F_Sharp|F#}}==
<syntaxhighlight lang="fsharp">
// Append numbers at same position in strings. Nigel Galloway: December 29th., 2021
let rec fG n g l=seq{match n,g,l with (n::x,g::y,l::z)->yield int((string n)+(string g)+(string l)); yield! fG x y z |_->()}
Line 183:
=={{header|Factor}}==
{{works with|Factor|0.99 2021-06-02}}
<syntaxhighlight lang="factor">USING: kernel math.parser math.ranges present prettyprint
sequences ;
 
Line 193:
 
=={{header|FreeBASIC}}==
<syntaxhighlight lang="freebasic">dim as integer list1(1 to 9) = {1,2,3,4,5,6,7,8,9}
dim as integer list2(1 to 9) = {10,11,12,13,14,15,16,17,18}
dim as integer list3(1 to 9) = {19,20,21,22,23,24,25,26,27}
Line 207:
 
=={{header|Go}}==
<syntaxhighlight lang="go">package main
 
import "fmt"
Line 230:
{{works with|jq}}
'''Works with gojq, the Go implementation of jq'''
<syntaxhighlight lang="jq">def list1 : [ range(1;10) ];
def list2 : [ range(10; 19)];
def list3 : [ range(19; 28) ];
Line 243:
 
=={{header|Julia}}==
<syntaxhighlight lang="julia">list1 = [1,2,3,4,5,6,7,8,9]
list2 = [10,11,12,13,14,15,16,17,18]
list3 = [19,20,21,22,23,24,25,26,27]
Line 251:
 
=={{header|Lambdatalk}}==
<syntaxhighlight lang=Scheme"scheme">
Using a function returning an array
 
Line 285:
 
=={{header|Mathematica}} / {{header|Wolfram Language}}==
<syntaxhighlight lang=Mathematica"mathematica">list1 = {1, 2, 3, 4, 5, 6, 7, 8, 9};
list2 = {10, 11, 12, 13, 14, 15, 16, 17, 18};
list3 = {19, 20, 21, 22, 23, 24, 25, 26, 27};
Line 297:
=={{header|Pascal}}==
The following <tt>program</tt> requires (at least) an ISO 7185-compliant processor supporting features at level&nbsp;1 (specifically “conformant array parameters” are being used).
<syntaxhighlight lang="pascal">program appendNumbersAtSamePositionInStrings(output);
 
type
Line 392:
 
=={{header|Perl}}==
<syntaxhighlight lang="perl">use strict;
use warnings;
 
Line 415:
 
=={{header|Phix}}==
<!--<syntaxhighlight lang=Phix"phix">(phixonline)-->
<span style="color: #7060A8;">printf</span><span style="color: #0000FF;">(</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"%V%V\n"</span><span style="color: #0000FF;">,</span><span style="color: #7060A8;">repeat</span><span style="color: #0000FF;">(</span><span style="color: #7060A8;">apply</span><span style="color: #0000FF;">(</span><span style="color: #7060A8;">apply</span><span style="color: #0000FF;">(</span><span style="color: #004600;">true</span><span style="color: #0000FF;">,</span><span style="color: #7060A8;">vslice</span><span style="color: #0000FF;">,{{</span><span style="color: #7060A8;">sq_mul</span><span style="color: #0000FF;">({</span><span style="color: #7060A8;">tagset</span><span style="color: #0000FF;">(</span><span style="color: #000000;">9</span><span style="color: #0000FF;">),</span><span style="color: #7060A8;">tagset</span><span style="color: #0000FF;">(</span><span style="color: #000000;">18</span><span style="color: #0000FF;">,</span><span style="color: #000000;">10</span><span style="color: #0000FF;">),</span><span style="color: #7060A8;">tagset</span><span style="color: #0000FF;">(</span><span style="color: #000000;">27</span><span style="color: #0000FF;">,</span><span style="color: #000000;">19</span><span style="color: #0000FF;">)},{</span><span style="color: #000000;">1e4</span><span style="color: #0000FF;">,</span><span style="color: #000000;">1e2</span><span style="color: #0000FF;">,</span><span style="color: #000000;">1</span><span style="color: #0000FF;">})},</span><span style="color: #7060A8;">tagset</span><span style="color: #0000FF;">(</span><span style="color: #000000;">9</span><span style="color: #0000FF;">)}),</span><span style="color: #7060A8;">sum</span><span style="color: #0000FF;">),</span><span style="color: #000000;">2</span><span style="color: #0000FF;">))</span>
<!--</syntaxhighlight>-->
Line 424:
 
=={{header|Python}}==
<syntaxhighlight lang="python">list1 = [1, 2, 3, 4, 5, 6, 7, 8, 9]
list2 = [10, 11, 12, 13, 14, 15, 16, 17, 18]
list3 = [19, 20, 21, 22, 23, 24, 25, 26, 27]
Line 435:
 
which is also expressible as a map:
<syntaxhighlight lang="python">print(list(map(
lambda x, y, z: f'{x}{y}{z}',
[1, 2, 3, 4, 5, 6, 7, 8, 9],
Line 446:
=={{header|Raku}}==
Various manipulations.
<syntaxhighlight lang=perl6"raku" line>my @lists = 1..9, 10..18, 19..27;
put [Z~] @lists; # the task
put [Z~] @lists».flip; # each component reversed
Line 458:
 
=={{header|Ring}}==
<syntaxhighlight lang="ring">
load "stdlib.ring"
list1 = [1,2,3,4,5,6,7,8,9]
Line 491:
 
=={{header|Ruby}}==
<syntaxhighlight lang="ruby">list1 = (1..9) .to_a
list2 = (10..18).to_a
list3 = (19..27).to_a
Line 501:
 
=={{header|Sidef}}==
<syntaxhighlight lang="ruby">var lists = [
[1,2,3,4,5,6,7,8,9],
[10,11,12,13,14,15,16,17,18],
Line 516:
=={{header|Vlang}}==
{{trans|go}}
<syntaxhighlight lang="vlang">fn main() {
list1 := [1, 2, 3, 4, 5, 6, 7, 8, 9]!
list2 := [10, 11, 12, 13, 14, 15, 16, 17, 18]!
Line 530:
 
=={{header|Wren}}==
<syntaxhighlight lang="ecmascript">var list1 = (1..9).toList
var list2 = (10..18).toList
var list3 = (19..27).toList
Line 542:
 
=={{header|XPL0}}==
<syntaxhighlight lang=XPL0"xpl0">intI;forI:=1to9do[IntOut(0,I*10000+(I+9)*100+I+18);ChOut(0,^ )]</syntaxhighlight>
{{out}}
<pre>
10,333

edits