langs a-z

This commit is contained in:
Ingy döt Net 2013-04-10 22:43:41 -07:00
parent db842d013d
commit d066446780
11389 changed files with 98361 additions and 1020 deletions

View file

@ -0,0 +1,26 @@
# Find Common Directory Path
# Input is an array of strings holding the paths
function Get-CommonDirectoryPath($paths){
# Convert each path into array of tokens (i.e. convert array into jagged array)
for($i=0; $i -lt $paths.Count; $i++) {
$paths[$i] = ($paths[$i].TrimStart('/').Split('/'))
}
# Loop through tokens
$c = -1
$found = $false
do { # Do Until loop used to handle paths with different number of directories
$t = $paths[0][++$c]
for($r = 1; $r -lt $paths.Count; $r++) {
if ($t -ne $paths[$r][$c]) { $found=$true; break }
}
} until ($found)
# Return the answer
for($i=0; $i -lt $c; $i++) {$s += "/"+$paths[0][$i]}
return $s
}
# Main Entry Point
"The common directory path is " + (Get-CommonDirectoryPath ("/home/user1/tmp/coverage/test", "/home/user1/tmp/covert/operator", "/home/user1/tmp/coven/members"))

View file

@ -0,0 +1 @@
The common directory path is /home/user1/tmp