Longest string challenge: Difference between revisions
Content deleted Content added
mNo edit summary |
|||
Line 1,262: | Line 1,262: | ||
[1,3] = ggg |
[1,3] = ggg |
||
} </pre> |
} </pre> |
||
=={{header|Nanoquery}}== |
|||
{{trans|Python}} |
|||
<lang Nanoquery>import Nanoquery.IO |
|||
def longer(a, b) |
|||
try |
|||
b[len(a)-1] |
|||
return false |
|||
catch |
|||
return true |
|||
end |
|||
end |
|||
print "enter filename: " |
|||
$f = new(File, input()) |
|||
longest = "" |
|||
lines = "" |
|||
for x in $f.read() |
|||
if longer(x, longest) |
|||
lines = x |
|||
longest = x |
|||
else if !longer(longest, x) |
|||
lines += "\n" + x |
|||
end |
|||
end |
|||
println lines</lang> |
|||
{{out}} |
|||
<pre>ccc |
|||
ddd |
|||
ggg</pre> |
|||
=={{header|OCaml}}== |
=={{header|OCaml}}== |