Longest string challenge: Difference between revisions

Content deleted Content added
Thundergnat (talk | contribs)
Rename Perl 6 -> Raku, alphabetize, minor clean-up
Line 70: Line 70:
At the end of the day for the implementer this should be a bit of fun. As an implementer you represent the expertise in your language, the reader may have no knowledge of your language. For the reader it should give them insight into how people think outside the box in other languages. Comments, especially for non-obvious (to the reader) bits will be extremely helpful. While the implementations may be a bit artificial in the context of this task, the general techniques may be useful elsewhere.
At the end of the day for the implementer this should be a bit of fun. As an implementer you represent the expertise in your language, the reader may have no knowledge of your language. For the reader it should give them insight into how people think outside the box in other languages. Comments, especially for non-obvious (to the reader) bits will be extremely helpful. While the implementations may be a bit artificial in the context of this task, the general techniques may be useful elsewhere.
<br><br>
<br><br>

=={{header|Ada}}==
=={{header|Ada}}==


Line 547: Line 547:
}
}
MsgBox % buffer</lang>
MsgBox % buffer</lang>

=={{header|AWK}}==
=={{header|AWK}}==


Line 1,446: Line 1,447:
substr($_, length($l)) and $all = $l = $_
substr($_, length($l)) and $all = $l = $_
or substr($l, length) or $all .= $_;</lang>
or substr($l, length) or $all .= $_;</lang>

=={{header|Perl 6}}==

<lang perl6>my $l = ''; # Sample longest string seen.
my $a = ''; # Accumulator to save longest strings.

while get() -> $s {
my $n = "$s\n";
if $n.substr($l.chars) { # Is new string longer?
$a = $l = $n; # Reset accumulator.
}
elsif !$l.substr($n.chars) { # Same length?
$a ~= $n; # Accumulate it.
}
}
print $a;</lang>

Given the example input, returns:
<pre>ccc
ddd
ggg</pre>


=={{header|Phix}}==
=={{header|Phix}}==
Line 1,848: Line 1,828:
[else (loop O (cdr C) i:rI rO i:rC)])))
[else (loop O (cdr C) i:rI rO i:rC)])))
</lang>
</lang>

=={{header|Raku}}==
(formerly Perl 6)

<lang perl6>my $l = ''; # Sample longest string seen.
my $a = ''; # Accumulator to save longest strings.

while get() -> $s {
my $n = "$s\n";
if $n.substr($l.chars) { # Is new string longer?
$a = $l = $n; # Reset accumulator.
}
elsif !$l.substr($n.chars) { # Same length?
$a ~= $n; # Accumulate it.
}
}
print $a;</lang>

Given the example input, returns:
<pre>ccc
ddd
ggg</pre>


=={{header|REXX}}==
=={{header|REXX}}==