RosettaCodeData/Task/Search-a-list/Nim/search-a-list.nim
2016-12-05 23:44:36 +01:00

8 lines
266 B
Nim

let haystack = ["Zig","Zag","Wally","Ronald","Bush","Krusty","Charlie","Bush","Bozo"]
for needle in ["Bush", "Washington"]:
let f = haystack.find(needle)
if f >= 0:
echo f, " ", needle
else:
raise newException(ValueError, needle & " not in haystack")