Find common directory path: Difference between revisions
→OCaml: simplify
m (→{{header|Wren}}: Changed to Wren S/H) |
(→OCaml: simplify) |
||
Line 1,727:
=={{header|OCaml}}==
| x :: xs, y :: ys when x = y -> x :: common_prefix xs ys
let common_prefix_all = function
▲<syntaxhighlight lang="ocaml">let rec aux acc paths =
| _ -> []
let
▲ | [] -> invalid_arg "common_prefix"
|> common_prefix_all
▲ | dirs ->
▲ let paths = List.map (Str.split (Str.regexp_string sep)) dirs in
▲ (sep ^ (String.concat sep res))
let
common_ancestor ~sep:"/" [
"/home/user1/tmp/coverage/test";
"/home/user1/tmp/covert/operator";
"/home/user1/tmp/coven/members";
] = "/home/user1/tmp"
▲;;</syntaxhighlight>
=={{header|OpenEdge/Progress}}==
|