Sort by Length for OCaml Golf Competition by shimomura(rakuda)

open List\x0d
let rec i?(s=ref[])?(l=read_line())_=try s:=l::!s;i~s()with e-> !s;;\x0d
let c?(k=String.length)a b=let n=k a-k b in n+(abs n-1)*(compare b a);;\x0d
map(Printf.printf"%s\n")(sort c(i()));;

Note that non-ascii characters in the above source code will be escaped (such as \x9f).

download

return to the top page