Largest int from concatenated ints: Difference between revisions

Content added Content deleted
(→‎{{header|Kotlin}}: Update Kotlin)
Line 276: Line 276:
=={{header|Ceylon}}==
=={{header|Ceylon}}==
{{trans|Kotlin}}
{{trans|Kotlin}}
{{works with|Ceylon|1.2}}
{{works with|Ceylon|1.2.1}}
<lang ceylon>shared void run() {
<lang ceylon>shared void run2() {
function intConcatenationComparer(Integer x, Integer y) {
function intConcatenationComparer(Integer x, Integer y) {
value xy = parseInteger(x.string + y.string) else -1;
assert(exists xy = parseInteger(x.string + y.string),
value yx = parseInteger(y.string + x.string) else -1;
exists yx = parseInteger(y.string + x.string));
return yx <=> xy;
return yx <=> xy;
}
}
function biggestConcatenation(Integer* ints) => "".join(ints.sort(intConcatenationComparer));
function biggestConcatenation(Integer* ints) => "".join(ints.sort(intConcatenationComparer));

value test1 = {1, 34, 3, 98, 9, 76, 45, 4};
value test1 = {1, 34, 3, 98, 9, 76, 45, 4};
value test2 = {54, 546, 548, 60};
value test2 = {54, 546, 548, 60};