Anonymous user
Largest int from concatenated ints: Difference between revisions
added ocaml
(Undo revision 154884 by Spoon! Less obscure.) |
(added ocaml) |
||
Line 97:
<lang j> maxnum&> 1 34 3 98 9 76 45 4 ; 54 546 548 60
998764543431 6054854654</lang>
=={{header|Java}}==
{{works with|Java|1.5+}}
Line 145 ⟶ 146:
<pre>998764543431
6054854654</pre>
=={{header|OCaml}}==
<lang ocaml>let myCompare a b = String.compare (b ^ a) (a ^ b)
let icsort nums = String.concat "" (List.sort myCompare (List.map string_of_int nums))</lang>
;testing
<pre>
# icsort [1;34;3;98;9;76;45;4];;
- : string = "998764543431"
# icsort [54;546;548;60];;
- : string = "6054854654"
</pre>
=={{header|Perl 6}}==
|