new files
This commit is contained in:
parent
3af7344581
commit
86c034bb8b
1364 changed files with 21352 additions and 0 deletions
21
Task/Search-a-list/AWK/search-a-list.awk
Normal file
21
Task/Search-a-list/AWK/search-a-list.awk
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
#! /usr/bin/awk -f
|
||||
BEGIN {
|
||||
# create the array, using the word as index...
|
||||
words="Zig Zag Wally Ronald Bush Krusty Charlie Bush Bozo";
|
||||
split(words, haystack_byorder, " ");
|
||||
j=0;
|
||||
for(idx in haystack_byorder) {
|
||||
haystack[haystack_byorder[idx]] = j;
|
||||
j++;
|
||||
}
|
||||
# now check for needle (we know it is there, so no "else")...
|
||||
if ( "Bush" in haystack ) {
|
||||
print "Bush is at " haystack["Bush"];
|
||||
}
|
||||
# check for unexisting needle
|
||||
if ( "Washington" in haystack ) {
|
||||
print "impossible";
|
||||
} else {
|
||||
print "Washington is not here";
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue