Data update
This commit is contained in:
parent
5150844a7d
commit
4bb20c9b71
7735 changed files with 38060 additions and 199180 deletions
|
|
@ -1,22 +0,0 @@
|
|||
function range-expansion($array) {
|
||||
function expansion($arr) {
|
||||
if($arr) {
|
||||
$arr = $arr.Split(',')
|
||||
$arr | foreach{
|
||||
$a = $_
|
||||
$b, $c, $d, $e = $a.Split('-')
|
||||
switch($a) {
|
||||
$b {return $a}
|
||||
"-$c" {return $a}
|
||||
"$b-$c" {return "$(([Int]$b)..([Int]$c))"}
|
||||
"-$c-$d" {return "$(([Int]$("-$c"))..([Int]$d))"}
|
||||
"-$c--$e" {return "$(([Int]$("-$c"))..([Int]$("-$e")))"}
|
||||
}
|
||||
}
|
||||
} else {""}
|
||||
}
|
||||
$OFS = ", "
|
||||
"$(expansion $array)"
|
||||
$OFS = " "
|
||||
}
|
||||
range-expansion "-6,-3--1,3-5,7-11,14,15,17-20"
|
||||
|
|
@ -1,42 +0,0 @@
|
|||
function Expand-Range
|
||||
{
|
||||
[CmdletBinding()]
|
||||
[OutputType([int])]
|
||||
Param
|
||||
(
|
||||
[Parameter(Mandatory=$true,
|
||||
Position=0)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[ValidatePattern('^[0-9,-]*$')]
|
||||
[string]
|
||||
$Range
|
||||
)
|
||||
|
||||
try
|
||||
{
|
||||
if ($Range -match '-,') # I'm not good enough to weed this case out with Regex
|
||||
{
|
||||
throw "Input string was not in a correct format."
|
||||
}
|
||||
|
||||
[int[]]$output = $Range -split ',' | ForEach-Object {
|
||||
|
||||
[int[]]$array = $_ -split '(?<=\d)-'
|
||||
|
||||
if ($array.Count -gt 1) # $array contains one or two elements
|
||||
{
|
||||
$array[0]..$array[1] # two elements = start and end of range
|
||||
}
|
||||
else
|
||||
{
|
||||
$array # one element = an integer
|
||||
}
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw "Input string was not in a correct format."
|
||||
}
|
||||
|
||||
$output
|
||||
}
|
||||
|
|
@ -1 +0,0 @@
|
|||
(Expand-Range "-6,-3--1,3-5,7-11,14,15,17-20") -join ", "
|
||||
Loading…
Add table
Add a link
Reference in a new issue