Minimum numbers of three lists: Difference between revisions
Content added Content deleted
No edit summary |
Thundergnat (talk | contribs) m (syntax highlighting fixup automation) |
||
Line 17: | Line 17: | ||
{{trans|Python}} |
{{trans|Python}} |
||
< |
<syntaxhighlight lang="11l">V numbers1 = [5, 45, 23, 21, 67] |
||
V numbers2 = [43, 22, 78, 46, 38] |
V numbers2 = [43, 22, 78, 46, 38] |
||
V numbers3 = [9, 98, 12, 98, 53] |
V numbers3 = [9, 98, 12, 98, 53] |
||
Line 23: | Line 23: | ||
V numbers = (0 .< numbers1.len).map(i -> min(:numbers1[i], :numbers2[i], :numbers3[i])) |
V numbers = (0 .< numbers1.len).map(i -> min(:numbers1[i], :numbers2[i], :numbers3[i])) |
||
print(numbers)</ |
print(numbers)</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
Line 31: | Line 31: | ||
=={{header|Ada}}== |
=={{header|Ada}}== |
||
< |
<syntaxhighlight lang="ada">with Ada.Text_Io; use Ada.Text_Io; |
||
procedure Minimum_Three_Lists is |
procedure Minimum_Three_Lists is |
||
Line 58: | Line 58: | ||
end loop; |
end loop; |
||
New_Line; |
New_Line; |
||
end Minimum_Three_Lists;</ |
end Minimum_Three_Lists;</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
<pre> 5 22 12 21 38</pre> |
<pre> 5 22 12 21 38</pre> |
||
Line 65: | Line 65: | ||
Generallising a little... |
Generallising a little... |
||
{{libheader|ALGOL 68-rows}} |
{{libheader|ALGOL 68-rows}} |
||
< |
<syntaxhighlight lang="algol68">BEGIN # construct a list of the minimum values of some other lists # |
||
# lists are represented by arrays in this sample # |
# lists are represented by arrays in this sample # |
||
PR read "rows.incl.a68" PR # row-related utilities # |
PR read "rows.incl.a68" PR # row-related utilities # |
||
Line 97: | Line 97: | ||
# display the minimum values for each element in the lists # |
# display the minimum values for each element in the lists # |
||
SHOW min( ( numbers1, numbers2, numbers3 ) ) |
SHOW min( ( numbers1, numbers2, numbers3 ) ) |
||
END</ |
END</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
<pre> |
<pre> |
||
Line 104: | Line 104: | ||
=={{header|ALGOL W}}== |
=={{header|ALGOL W}}== |
||
< |
<syntaxhighlight lang="algolw">begin % show the minimum elements of three lists % |
||
integer array numbers1, numbers2, numbers3 ( 1 :: 5 ); |
integer array numbers1, numbers2, numbers3 ( 1 :: 5 ); |
||
integer pos; |
integer pos; |
||
Line 117: | Line 117: | ||
writeon( i_w := 1, s_w := 0, " ", m ) |
writeon( i_w := 1, s_w := 0, " ", m ) |
||
end for_i; |
end for_i; |
||
end.</ |
end.</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
<pre> |
<pre> |
||
Line 124: | Line 124: | ||
=={{header|AutoHotkey}}== |
=={{header|AutoHotkey}}== |
||
< |
<syntaxhighlight lang="autohotkey">Numbers1 := [5,45,23,21,67] |
||
Numbers2 := [43,22,78,46,38] |
Numbers2 := [43,22,78,46,38] |
||
Numbers3 := [9,98,12,98,53] |
Numbers3 := [9,98,12,98,53] |
||
Line 138: | Line 138: | ||
for i, v in Numbers |
for i, v in Numbers |
||
result .= v ", " |
result .= v ", " |
||
MsgBox % result := "[" . Trim(result, ", ") . "]"</ |
MsgBox % result := "[" . Trim(result, ", ") . "]"</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
<pre>[5, 22, 12, 21, 38]</pre> |
<pre>[5, 22, 12, 21, 38]</pre> |
||
=={{header|AWK}}== |
=={{header|AWK}}== |
||
<syntaxhighlight lang="awk"> |
|||
<lang AWK> |
|||
# syntax: GAWK -f MINIMUM_NUMBERS_OF_THREE_LISTS.AWK |
# syntax: GAWK -f MINIMUM_NUMBERS_OF_THREE_LISTS.AWK |
||
BEGIN { |
BEGIN { |
||
Line 161: | Line 161: | ||
} |
} |
||
function min(x,y) { return((x < y) ? x : y) } |
function min(x,y) { return((x < y) ? x : y) } |
||
</syntaxhighlight> |
|||
</lang> |
|||
{{out}} |
{{out}} |
||
<pre> |
<pre> |
||
Line 168: | Line 168: | ||
=={{header|C}}== |
=={{header|C}}== |
||
< |
<syntaxhighlight lang="c">#include <stdio.h> |
||
int min(int a, int b) { |
int min(int a, int b) { |
||
Line 187: | Line 187: | ||
printf("\n"); |
printf("\n"); |
||
return 0; |
return 0; |
||
}</ |
}</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
Line 195: | Line 195: | ||
=={{header|F_Sharp|F#}}== |
=={{header|F_Sharp|F#}}== |
||
< |
<syntaxhighlight lang="fsharp"> |
||
// Minimum numbers of three lists. Nigel Galloway: October 26th., 2021 |
// Minimum numbers of three lists. Nigel Galloway: October 26th., 2021 |
||
let N1,N2,N3=[5;45;23;21;67],[43;22;78;46;38],[9;98;12;98;53] |
let N1,N2,N3=[5;45;23;21;67],[43;22;78;46;38],[9;98;12;98;53] |
||
printfn "%A" (List.zip3 N1 N2 N3|>List.map(fun(n,g,l)->min (min n g) l)) |
printfn "%A" (List.zip3 N1 N2 N3|>List.map(fun(n,g,l)->min (min n g) l)) |
||
</syntaxhighlight> |
|||
</lang> |
|||
{{out}} |
{{out}} |
||
<pre> |
<pre> |
||
Line 207: | Line 207: | ||
=={{header|Factor}}== |
=={{header|Factor}}== |
||
{{works with|Factor|0.99 2021-06-02}} |
{{works with|Factor|0.99 2021-06-02}} |
||
< |
<syntaxhighlight lang="factor">USING: math.order sequences prettyprint ; |
||
{ 5 45 23 21 67 } { 43 22 78 46 38 } { 9 98 12 98 53 } |
{ 5 45 23 21 67 } { 43 22 78 46 38 } { 9 98 12 98 53 } |
||
[ min min ] 3map .</ |
[ min min ] 3map .</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
<pre> |
<pre> |
||
Line 217: | Line 217: | ||
=={{header|Fermat}}== |
=={{header|Fermat}}== |
||
< |
<syntaxhighlight lang="fermat">[numbers1] := [(5,45,23,21,67)]; |
||
[numbers2] := [(43,22,78,46,38)]; |
[numbers2] := [(43,22,78,46,38)]; |
||
[numbers3] := [(9,98,12,98,53)]; |
[numbers3] := [(9,98,12,98,53)]; |
||
Line 226: | Line 226: | ||
Return(c[n]).; |
Return(c[n]).; |
||
for i = 1 to 5 do !!Minby( [numbers1], [numbers2], [numbers3], i ) od;</ |
for i = 1 to 5 do !!Minby( [numbers1], [numbers2], [numbers3], i ) od;</syntaxhighlight> |
||
{{out}}<pre> |
{{out}}<pre> |
||
Line 237: | Line 237: | ||
=={{header|FreeBASIC}}== |
=={{header|FreeBASIC}}== |
||
< |
<syntaxhighlight lang="freebasic">#define min(a, b) Iif(a<b,a,b) |
||
dim as integer numbers(1 to 3, 1 to 5) = _ |
dim as integer numbers(1 to 3, 1 to 5) = _ |
||
Line 244: | Line 244: | ||
for i as uinteger = 1 to 5 |
for i as uinteger = 1 to 5 |
||
print min( numbers(1, i), min(numbers(2,i), numbers(3, i) ) ) |
print min( numbers(1, i), min(numbers(2,i), numbers(3, i) ) ) |
||
next i</ |
next i</syntaxhighlight> |
||
{{out}}<pre> |
{{out}}<pre> |
||
Line 256: | Line 256: | ||
=={{header|Go}}== |
=={{header|Go}}== |
||
{{libheader|Go-rcu}} |
{{libheader|Go-rcu}} |
||
< |
<syntaxhighlight lang="go">package main |
||
import ( |
import ( |
||
Line 272: | Line 272: | ||
} |
} |
||
fmt.Println(numbers) |
fmt.Println(numbers) |
||
}</ |
}</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
Line 280: | Line 280: | ||
=={{header|Haskell}}== |
=={{header|Haskell}}== |
||
< |
<syntaxhighlight lang="haskell">import Data.List (transpose) |
||
numbers1, numbers2, numbers3 :: [Integer] |
numbers1, numbers2, numbers3 :: [Integer] |
||
Line 292: | Line 292: | ||
minimum |
minimum |
||
<$> transpose |
<$> transpose |
||
[numbers1, numbers2, numbers3]</ |
[numbers1, numbers2, numbers3]</syntaxhighlight> |
||
{{Out}} |
{{Out}} |
||
<pre>[5,22,12,21,38]</pre> |
<pre>[5,22,12,21,38]</pre> |
||
=={{header|JavaScript}}== |
=={{header|JavaScript}}== |
||
< |
<syntaxhighlight lang="javascript">(() => { |
||
"use strict"; |
"use strict"; |
||
Line 342: | Line 342: | ||
// MAIN --- |
// MAIN --- |
||
return JSON.stringify(main()); |
return JSON.stringify(main()); |
||
})();</ |
})();</syntaxhighlight> |
||
{{Out}} |
{{Out}} |
||
<pre>[5,22,12,21,38]</pre> |
<pre>[5,22,12,21,38]</pre> |
||
Line 349: | Line 349: | ||
{{works with|jq}} |
{{works with|jq}} |
||
'''Works with gojq, the Go implementation of jq''' |
'''Works with gojq, the Go implementation of jq''' |
||
Two solutions are presented - an iterative one that mirrors the problem description, and one that is functional:< |
Two solutions are presented - an iterative one that mirrors the problem description, and one that is functional:<syntaxhighlight lang="jq">def numbers1: [ 5, 45, 23, 21, 67]; |
||
def numbers2: [43, 22, 78, 46, 38]; |
def numbers2: [43, 22, 78, 46, 38]; |
||
def numbers3: [ 9, 98, 12, 98, 53];</ |
def numbers3: [ 9, 98, 12, 98, 53];</syntaxhighlight> |
||
'''Mirroring the requirements''' |
'''Mirroring the requirements''' |
||
< |
<syntaxhighlight lang="jq">[range(0;5) |
||
| [numbers1[.], numbers2[.], numbers3[.]] | min]</ |
| [numbers1[.], numbers2[.], numbers3[.]] | min]</syntaxhighlight> |
||
'''Functional solution''' |
'''Functional solution''' |
||
< |
<syntaxhighlight lang="jq">[numbers1, numbers2, numbers3] |
||
| transpose |
| transpose |
||
| map(min)</ |
| map(min)</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
<pre> |
<pre> |
||
Line 366: | Line 366: | ||
=={{header|Julia}}== |
=={{header|Julia}}== |
||
Computed in the REPL, using matrix functions. |
Computed in the REPL, using matrix functions. |
||
< |
<syntaxhighlight lang="julia"> |
||
julia> Numbers1 = [5,45,23,21,67] |
julia> Numbers1 = [5,45,23,21,67] |
||
5-element Vector{Int64}: |
5-element Vector{Int64}: |
||
Line 406: | Line 406: | ||
21 |
21 |
||
38 |
38 |
||
</syntaxhighlight> |
|||
</lang> |
|||
=={{header|Mathematica}} / {{header|Wolfram Language}}== |
=={{header|Mathematica}} / {{header|Wolfram Language}}== |
||
< |
<syntaxhighlight lang="mathematica">Min /@ Transpose@{{5, 45, 23, 21, 67}, {43, 22, 78, 46, 38}, {9, 98, |
||
12, 98, 53}}</ |
12, 98, 53}}</syntaxhighlight> |
||
{{out}}<pre> |
{{out}}<pre> |
||
Line 416: | Line 416: | ||
=={{header|Nim}}== |
=={{header|Nim}}== |
||
< |
<syntaxhighlight lang="nim">const |
||
Numbers1 = [ 5, 45, 23, 21, 67] |
Numbers1 = [ 5, 45, 23, 21, 67] |
||
Numbers2 = [43, 22, 78, 46, 38] |
Numbers2 = [43, 22, 78, 46, 38] |
||
Line 426: | Line 426: | ||
numbers[i] = min(min(Numbers1[i], Numbers2[i]), Numbers3[i]) |
numbers[i] = min(min(Numbers1[i], Numbers2[i]), Numbers3[i]) |
||
echo numbers</ |
echo numbers</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
Line 432: | Line 432: | ||
=={{header|ooRexx}}== |
=={{header|ooRexx}}== |
||
< |
<syntaxhighlight lang="oorexx">/* REXX */ |
||
l.1=.array~of( 5, 45, 23, 21, 67) |
l.1=.array~of( 5, 45, 23, 21, 67) |
||
l.2=.array~of(43, 22, 78, 46, 38) |
l.2=.array~of(43, 22, 78, 46, 38) |
||
Line 440: | Line 440: | ||
o=o min(l.1[i],l.2[i],l.3[i]) |
o=o min(l.1[i],l.2[i],l.3[i]) |
||
End |
End |
||
Say strip(o)</ |
Say strip(o)</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
<pre>[5 22 12 21 38]</pre> |
<pre>[5 22 12 21 38]</pre> |
||
Line 446: | Line 446: | ||
=={{header|Perl}}== |
=={{header|Perl}}== |
||
< |
<syntaxhighlight lang="perl">use strict; |
||
use warnings; |
use warnings; |
||
use List::Util 'min'; |
use List::Util 'min'; |
||
Line 454: | Line 454: | ||
for my $i (0 .. $#{ $lists[0] }) { |
for my $i (0 .. $#{ $lists[0] }) { |
||
print ' ' . min map { $lists[$_][$i] } 0..$#lists; |
print ' ' . min map { $lists[$_][$i] } 0..$#lists; |
||
}</ |
}</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
<pre> 5 22 12 21 38</pre> |
<pre> 5 22 12 21 38</pre> |
||
=={{header|Phix}}== |
=={{header|Phix}}== |
||
<!--< |
<!--<syntaxhighlight lang="phix">(phixonline)--> |
||
<span style="color: #008080;">with</span> <span style="color: #008080;">javascript_semantics</span> |
<span style="color: #008080;">with</span> <span style="color: #008080;">javascript_semantics</span> |
||
<span style="color: #008080;">constant</span> <span style="color: #000000;">N123</span> <span style="color: #0000FF;">=</span> <span style="color: #0000FF;">{{</span> <span style="color: #000000;">5</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">45</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">23</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">21</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">67</span><span style="color: #0000FF;">},</span> |
<span style="color: #008080;">constant</span> <span style="color: #000000;">N123</span> <span style="color: #0000FF;">=</span> <span style="color: #0000FF;">{{</span> <span style="color: #000000;">5</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">45</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">23</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">21</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">67</span><span style="color: #0000FF;">},</span> |
||
Line 465: | Line 465: | ||
<span style="color: #0000FF;">{</span> <span style="color: #000000;">9</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">98</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">12</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">98</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">53</span><span style="color: #0000FF;">}}</span> |
<span style="color: #0000FF;">{</span> <span style="color: #000000;">9</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">98</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">12</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">98</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">53</span><span style="color: #0000FF;">}}</span> |
||
<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\n"</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: #000000;">N123</span><span style="color: #0000FF;">},</span><span style="color: #7060A8;">tagset</span><span style="color: #0000FF;">(</span><span style="color: #000000;">5</span><span style="color: #0000FF;">)}),</span><span style="color: #7060A8;">minsq</span><span style="color: #0000FF;">)})</span> |
<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\n"</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: #000000;">N123</span><span style="color: #0000FF;">},</span><span style="color: #7060A8;">tagset</span><span style="color: #0000FF;">(</span><span style="color: #000000;">5</span><span style="color: #0000FF;">)}),</span><span style="color: #7060A8;">minsq</span><span style="color: #0000FF;">)})</span> |
||
<!--</ |
<!--</syntaxhighlight>--> |
||
{{out}} |
{{out}} |
||
<pre> |
<pre> |
||
Line 472: | Line 472: | ||
=={{header|Plain English}}== |
=={{header|Plain English}}== |
||
< |
<syntaxhighlight lang="plainenglish">To run: |
||
Start up. |
Start up. |
||
Create a first list and a second list and a third list. |
Create a first list and a second list and a third list. |
||
Line 535: | Line 535: | ||
If the entry's next is not nil, write ", " on the console without advancing. |
If the entry's next is not nil, write ", " on the console without advancing. |
||
Put the entry's next into the entry. |
Put the entry's next into the entry. |
||
Repeat.</ |
Repeat.</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
<pre> |
<pre> |
||
Line 542: | Line 542: | ||
=={{header|Python}}== |
=={{header|Python}}== |
||
< |
<syntaxhighlight lang="python">numbers1 = [5,45,23,21,67] |
||
numbers2 = [43,22,78,46,38] |
numbers2 = [43,22,78,46,38] |
||
numbers3 = [9,98,12,98,53] |
numbers3 = [9,98,12,98,53] |
||
Line 548: | Line 548: | ||
numbers = [min(numbers1[i],numbers2[i],numbers3[i]) for i in range(0,len(numbers1))] |
numbers = [min(numbers1[i],numbers2[i],numbers3[i]) for i in range(0,len(numbers1))] |
||
print(numbers)</ |
print(numbers)</syntaxhighlight> |
||
{{Output}} |
{{Output}} |
||
<pre>[5, 22, 12, 21, 38]</pre> |
<pre>[5, 22, 12, 21, 38]</pre> |
||
Line 554: | Line 554: | ||
Or, in terms of zip: |
Or, in terms of zip: |
||
< |
<syntaxhighlight lang="python">'''Minimum value in each column''' |
||
numbers1 = [5, 45, 23, 21, 67] |
numbers1 = [5, 45, 23, 21, 67] |
||
Line 563: | Line 563: | ||
min(x) for x |
min(x) for x |
||
in zip(*[numbers1, numbers2, numbers3]) |
in zip(*[numbers1, numbers2, numbers3]) |
||
])</ |
])</syntaxhighlight> |
||
{{Out}} |
{{Out}} |
||
<pre>[5, 22, 12, 21, 38]</pre> |
<pre>[5, 22, 12, 21, 38]</pre> |
||
=={{header|Raku}}== |
=={{header|Raku}}== |
||
<lang |
<syntaxhighlight lang="raku" line>say [Zmin] (5,45,23,21,67), (43,22,78,46,38), (9,98,12,98,53);</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
<pre>(5 22 12 21 38)</pre> |
<pre>(5 22 12 21 38)</pre> |
||
=={{header|Red}}== |
=={{header|Red}}== |
||
< |
<syntaxhighlight lang="rebol">Red [ |
||
Red-version: 0.6.4 |
Red-version: 0.6.4 |
||
Description: "Find the element-wise minimum of three lists" |
Description: "Find the element-wise minimum of three lists" |
||
Line 586: | Line 586: | ||
result/:i: min min numbers1/:i numbers2/:i numbers3/:i |
result/:i: min min numbers1/:i numbers2/:i numbers3/:i |
||
] |
] |
||
print result</ |
print result</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
<pre> |
<pre> |
||
Line 593: | Line 593: | ||
=={{header|REXX}}== |
=={{header|REXX}}== |
||
< |
<syntaxhighlight lang="rexx">/* REXX */ |
||
w= 5 45 23 21 67 43 22 78 46 38 9 98 12 98 53 |
w= 5 45 23 21 67 43 22 78 46 38 9 98 12 98 53 |
||
Do i=1 To 3 |
Do i=1 To 3 |
||
Line 604: | Line 604: | ||
o=o min(l.1.j,l.2.j,l.3.j) |
o=o min(l.1.j,l.2.j,l.3.j) |
||
End |
End |
||
Say strip(o)</ |
Say strip(o)</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
<pre>5 22 12 21 38</pre> |
<pre>5 22 12 21 38</pre> |
||
=={{header|Ring}}== |
=={{header|Ring}}== |
||
< |
<syntaxhighlight lang="ring">see "? "working..." |
||
Num1 = [ 5,45,23,21,67] |
Num1 = [ 5,45,23,21,67] |
||
Line 627: | Line 627: | ||
rv = ar[1] |
rv = ar[1] |
||
for n = 2 to len(ar) rv += "," + ar[n] next |
for n = 2 to len(ar) rv += "," + ar[n] next |
||
return "[" + rv + "]"</ |
return "[" + rv + "]"</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
<pre> |
<pre> |
||
Line 636: | Line 636: | ||
=={{header|Ruby}}== |
=={{header|Ruby}}== |
||
< |
<syntaxhighlight lang="ruby">numbers1 = [ 5, 45, 23, 21, 67] |
||
numbers2 = [43, 22, 78, 46, 38] |
numbers2 = [43, 22, 78, 46, 38] |
||
numbers3 = [ 9, 98, 12, 98, 53] |
numbers3 = [ 9, 98, 12, 98, 53] |
||
p [numbers1, numbers2, numbers3].transpose.map(&:min)</ |
p [numbers1, numbers2, numbers3].transpose.map(&:min)</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
<pre>[5, 22, 12, 21, 38] |
<pre>[5, 22, 12, 21, 38] |
||
Line 646: | Line 646: | ||
=={{header|Sidef}}== |
=={{header|Sidef}}== |
||
< |
<syntaxhighlight lang="ruby">var lists = [ |
||
[ 5, 45, 23, 21, 67], |
[ 5, 45, 23, 21, 67], |
||
[43, 22, 78, 46, 38], |
[43, 22, 78, 46, 38], |
||
Line 652: | Line 652: | ||
] |
] |
||
say lists.zip.map{.min}</ |
say lists.zip.map{.min}</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
Line 660: | Line 660: | ||
=={{header|Vlang}}== |
=={{header|Vlang}}== |
||
< |
<syntaxhighlight lang="vlang">import math |
||
fn main() { |
fn main() { |
||
numbers1 := [5, 45, 23, 21, 67]! |
numbers1 := [5, 45, 23, 21, 67]! |
||
Line 670: | Line 670: | ||
} |
} |
||
println(numbers) |
println(numbers) |
||
}</ |
}</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
<pre>[5, 22, 12, 21, 38]</pre> |
<pre>[5, 22, 12, 21, 38]</pre> |
||
=={{header|Wren}}== |
=={{header|Wren}}== |
||
< |
<syntaxhighlight lang="ecmascript">var numbers1 = [ 5, 45, 23, 21, 67] |
||
var numbers2 = [43, 22, 78, 46, 38] |
var numbers2 = [43, 22, 78, 46, 38] |
||
var numbers3 = [ 9, 98, 12, 98, 53] |
var numbers3 = [ 9, 98, 12, 98, 53] |
||
var numbers = List.filled(5, 0) |
var numbers = List.filled(5, 0) |
||
for (n in 0..4) numbers[n] = numbers1[n].min(numbers2[n]).min(numbers3[n]) |
for (n in 0..4) numbers[n] = numbers1[n].min(numbers2[n]).min(numbers3[n]) |
||
System.print(numbers)</ |
System.print(numbers)</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
Line 688: | Line 688: | ||
=={{header|XPL0}}== |
=={{header|XPL0}}== |
||
< |
<syntaxhighlight lang="xpl0">func Min(A, B); |
||
int A, B; |
int A, B; |
||
return if A<B then A else B; |
return if A<B then A else B; |
||
Line 700: | Line 700: | ||
ChOut(0, ^ ); |
ChOut(0, ^ ); |
||
]; |
]; |
||
]</ |
]</syntaxhighlight> |
||
{{out}} |
{{out}} |