Collect and sort square numbers in ascending order from three lists: Difference between revisions

no edit summary
m (→‎{{header|Wren}}: Changed to Wren S/H)
No edit summary
 
(2 intermediate revisions by 2 users not shown)
Line 132:
4 9 16 25 36 36 49 81 121 144 169
</pre>
 
=={{header|BQN}}==
<syntaxhighlight lang="bqn">lists ← ⟨[3,4,34,25,9,12,36,56,36]
[2,8,81,169,34,55,76,49,7]
[75,121,75,144,35,16,46,35]⟩
Task ← ∧∘∾ ⌊⌾√⊸=⊸/¨
 
Task lists</syntaxhighlight>
{{out}}
<pre>⟨ 4 9 16 25 36 36 49 81 121 144 169 ⟩</pre>
 
=={{header|Delphi}}==
Line 272 ⟶ 282:
next i</syntaxhighlight>
{{out}}<pre>4 9 16 25 36 36 49 81 121 144 169</pre>
 
 
=={{header|Go}}==
Line 475 ⟶ 486:
<pre>REXX-ooRexx_5.0.0(MT)_64-bit 6.05 8 Sep 2020
Ordered squares: 4 9 16 25 36 36 49 81 121 144 169</pre>
 
=={{header|Pascal}}==
==={{header|Free Pascal}}===
<syntaxhighlight lang="pascal">
Program SortedSquares;
{$mode ObjFPC}{$H+}
 
Uses sysutils,fgl;
 
Type
tmap = specialize TFPGList<integer>;
 
Const List1: array Of integer = (3,4,34,25,9,12,36,56,36);
Const List2: array Of integer = (2,8,81,169,34,55,76,49,7);
Const List3: array Of integer = (75,121,75,144,35,16,46,35);
 
Var list : specialize TFPGList<integer>;
 
Procedure addtolist(arr : Array Of integer);
Var i : integer;
Begin
For i In arr Do
If ((frac(sqrt(i)) = 0) {check if a square, there will be no fraction}
And (list.indexof(i) = -1)) {make sure number isn't in list already}
Then list.add(i);
End;
 
Function CompareInt(Const Item1,Item2: Integer): Integer;
Begin
result := item1 - item2;
End;
 
Var i : integer;
Begin
list := specialize TFPGList<integer>.create;
addtolist(list1);
addtolist(list2);
addtolist(list3);
List.Sort(@CompareInt); {quick sort the list}
For i In list Do
write(i:4);
list.destroy;
End.
</syntaxhighlight>
{{out}}
<pre>
4 9 16 25 36 49 81 121 144 169
</pre>
 
=={{header|Perl}}==
44

edits