2016 Update

This commit is contained in:
Tina Müller 2016-12-05 22:15:40 +01:00
parent 948b86eafa
commit dcf5d15da3
7965 changed files with 139854 additions and 31002 deletions

View file

@ -0,0 +1,57 @@
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")

View file

@ -0,0 +1 @@
Find-Needle "house" $haystack

View file

@ -0,0 +1 @@
Find-Needle "house" $haystack -Verbose

View file

@ -0,0 +1 @@
Find-Needle "house" $haystack -LastIndex -Verbose

View file

@ -0,0 +1 @@
Find-Needle "title" $haystack -LastIndex -Verbose

View file

@ -0,0 +1 @@
Find-Needle "something" $haystack -Verbose