Find common directory path: Difference between revisions

Added Arturo implementation
(→‎{{header|Python}}: os.path.commonpath for Pythons 3.5+)
(Added Arturo implementation)
Line 182:
/home/user1/tmp
</pre>
 
=={{header|Arturo}}==
 
<lang rebol>commonPathPrefix: function [lst][
paths: map lst => [split.path &]
 
common: new []
firstPath: first paths
loop .with:'i firstPath 'part [
found: true
loop paths 'p [
if part <> get p i [
found: false
break
]
]
if found -> 'common ++ part
]
return "/" ++ join.path common
]
 
print commonPathPrefix [
"/home/user1/tmp/coverage/test"
"/home/user1/tmp/covert/operator"
"/home/user1/tmp/coven/members"
]</lang>
 
{{out}}
 
<pre>/home/user1/tmp</pre>
 
=={{header|AutoHotkey}}==
1,532

edits