import Data.List
haystack=["Zig","Zag","Wally","Ronald","Bush","Krusty","Charlie","Bush","Bozo"]
needles = ["Bush"]
map (\x -> (x, elemIndex x haystack)) needles
(let [haystack ["Zig" "Zag" "Wally" "Ronald" "Bush" "Krusty" "Charlie" "Bush" "Bozo"]]
(let [idx (.indexOf haystack "Bush")]
(if (neg? idx)
(println "NOT Found")
(println "Found"))))
package main
import "fmt"
func linearsearch(datalist []string, key string) bool {
for _, item := range datalist {
if item == key {
return true
}
}
return false
}
func main() {
items := []string{"Zig", "Zag", "Wally", "Ronald", "Bush", "Krusty", "Charlie", "Bush", "Bozo"}
fmt.Println(linearsearch(items, "Bush"))
}
var haystack = ['Zig', 'Zag', 'Wally', 'Ronald', 'Bush', 'Krusty', 'Charlie', 'Bush', 'Bozo']
var needles = ['Bush']
for (let i in needles) {
var found = false;
for (var j in haystack) {
if (haystack[j] == needles[i]) {
found = true;
break;
}
}
if (found)
console.log("Found")
else
console.log("NOT Found")
}