Sort by Length for OCaml Golf Competition by clairvy

open List
let rec s r=begin try s(read_line()::r)with End_of_file->r end
and f a b=if a=0then b else a;;
iter(fun x->print_endline(snd x)) (sort (fun a b->f (compare (fst a) (fst b)) (compare (snd a) (snd b))) (map (fun l->(String.length l,l)) (s [])));;

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

download

return to the top page