Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
12
Task/Search-a-list/E/search-a-list.e
Normal file
12
Task/Search-a-list/E/search-a-list.e
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
def haystack := ["Zig","Zag","Wally","Ronald","Bush","Krusty","Charlie","Bush","Bozo"]
|
||||
|
||||
/** meet the 'raise an exception' requirement */
|
||||
def find(needle) {
|
||||
switch (haystack.indexOf1(needle)) {
|
||||
match ==(-1) { throw("an exception") }
|
||||
match index { return index }
|
||||
}
|
||||
}
|
||||
|
||||
println(find("Ronald")) # prints 3
|
||||
println(find("McDonald")) # will throw
|
||||
Loading…
Add table
Add a link
Reference in a new issue