September 2017 Update
This commit is contained in:
parent
bba7bfd280
commit
ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions
36
Task/Map-range/PowerShell/map-range-1.psh
Normal file
36
Task/Map-range/PowerShell/map-range-1.psh
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
function Group-Range
|
||||
{
|
||||
[CmdletBinding()]
|
||||
[OutputType([PSCustomObject])]
|
||||
Param
|
||||
(
|
||||
[Parameter(Mandatory=$true,
|
||||
Position=0)]
|
||||
[ValidateCount(2,2)]
|
||||
[double[]]
|
||||
$Range1,
|
||||
|
||||
[Parameter(Mandatory=$true,
|
||||
Position=1)]
|
||||
[ValidateCount(2,2)]
|
||||
[double[]]
|
||||
$Range2,
|
||||
|
||||
[Parameter(Mandatory=$true,
|
||||
ValueFromPipeline=$true,
|
||||
Position=2)]
|
||||
[double]
|
||||
$Map
|
||||
)
|
||||
|
||||
Process
|
||||
{
|
||||
foreach ($number in $Map)
|
||||
{
|
||||
[PSCustomObject]@{
|
||||
Index = $number
|
||||
Mapping = $Range2[0] + ($number - $Range1[0]) * ($Range2[0] - $Range2[1]) / ($Range1[0] - $Range1[1])
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
1
Task/Map-range/PowerShell/map-range-2.psh
Normal file
1
Task/Map-range/PowerShell/map-range-2.psh
Normal file
|
|
@ -0,0 +1 @@
|
|||
0..10 | Group-Range (0,10) (-1,0)
|
||||
Loading…
Add table
Add a link
Reference in a new issue