Search a list: Difference between revisions

add E example
No edit summary
(add E example)
Line 357:
4 BUSH
</pre>
 
=={{header|E}}==
 
<lang e>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</lang>
 
=={{header|Haskell}}==