Data update
This commit is contained in:
parent
5150844a7d
commit
4bb20c9b71
7735 changed files with 38060 additions and 199180 deletions
|
|
@ -1,12 +0,0 @@
|
|||
function index($haystack,$needle) {
|
||||
$index = $haystack.IndexOf($needle)
|
||||
if($index -eq -1) {
|
||||
Write-Warning "$needle is absent"
|
||||
} else {
|
||||
$index
|
||||
}
|
||||
|
||||
}
|
||||
$haystack = @("word", "phrase", "preface", "title", "house", "line", "chapter", "page", "book", "house")
|
||||
index $haystack "house"
|
||||
index $haystack "paragraph"
|
||||
|
|
@ -1,57 +0,0 @@
|
|||
function Find-Needle
|
||||
{
|
||||
[CmdletBinding()]
|
||||
[OutputType([int])]
|
||||
Param
|
||||
(
|
||||
[Parameter(Mandatory=$true, Position=0)]
|
||||
[string]
|
||||
$Needle,
|
||||
|
||||
[Parameter(Mandatory=$true, Position=1)]
|
||||
[string[]]
|
||||
$Haystack,
|
||||
|
||||
[switch]
|
||||
$LastIndex
|
||||
)
|
||||
|
||||
if ($LastIndex)
|
||||
{
|
||||
$index = [Array]::LastIndexOf($Haystack,$Needle)
|
||||
|
||||
if ($index -eq -1)
|
||||
{
|
||||
Write-Verbose "Needle not found in Haystack"
|
||||
return $index
|
||||
}
|
||||
|
||||
if ((($Haystack | Group-Object | Where-Object Count -GT 1).Group).IndexOf($Needle) -ne -1)
|
||||
{
|
||||
Write-Verbose "Last needle found in Haystack at index $index"
|
||||
}
|
||||
else
|
||||
{
|
||||
Write-Verbose "Needle found in Haystack at index $index (No duplicates were found)"
|
||||
}
|
||||
|
||||
return $index
|
||||
}
|
||||
else
|
||||
{
|
||||
$index = [Array]::IndexOf($Haystack,$Needle)
|
||||
|
||||
if ($index -eq -1)
|
||||
{
|
||||
Write-Verbose "Needle not found in Haystack"
|
||||
}
|
||||
else
|
||||
{
|
||||
Write-Verbose "Needle found in Haystack at index $index"
|
||||
}
|
||||
|
||||
return $index
|
||||
}
|
||||
}
|
||||
|
||||
$haystack = @("word", "phrase", "preface", "title", "house", "line", "chapter", "page", "book", "house")
|
||||
|
|
@ -1 +0,0 @@
|
|||
Find-Needle "house" $haystack
|
||||
|
|
@ -1 +0,0 @@
|
|||
Find-Needle "house" $haystack -Verbose
|
||||
|
|
@ -1 +0,0 @@
|
|||
Find-Needle "house" $haystack -LastIndex -Verbose
|
||||
|
|
@ -1 +0,0 @@
|
|||
Find-Needle "title" $haystack -LastIndex -Verbose
|
||||
|
|
@ -1 +0,0 @@
|
|||
Find-Needle "something" $haystack -Verbose
|
||||
Loading…
Add table
Add a link
Reference in a new issue