Jump to content

Compare length of two strings: Difference between revisions

(→‎OCaml: add)
Line 1,447:
<pre>“marché”, byte length = 7, code points: 6
“marche”, byte length = 6, code points: 6</pre>
 
=={{header|OCaml}}==
<syntaxhighlight lang="ocaml">let () =
["abcd"; "123456789"; "abcdef"; "1234567"]
|> List.rev_map (fun s -> String.length s, s)
|> List.sort (Fun.flip compare)
|> List.iter (fun (l, s) -> Printf.printf "%u %s\n" l s)</syntaxhighlight>
{{out}}
<pre>
9 123456789
7 1234567
6 abcdef
4 abcd
</pre>
 
=={{header|Pascal}}==
559

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.