Another update from ingydotnet^djgoku
This commit is contained in:
parent
91df62d461
commit
948b86eafa
7604 changed files with 108452 additions and 22726 deletions
12
Task/Search-a-list/PowerShell/search-a-list.psh
Normal file
12
Task/Search-a-list/PowerShell/search-a-list.psh
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
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"
|
||||
Loading…
Add table
Add a link
Reference in a new issue