RosettaCodeData/Task/Search-a-list/R/search-a-list-2.r
Ingy döt Net 86c034bb8b new files
2013-04-10 12:38:42 -07:00

8 lines
429 B
R

haystack1 <- c("where", "is", "the", "needle", "I", "wonder")
haystack2 <- c("no", "sewing", "equipment", "in", "here")
haystack3 <- c("oodles", "of", "needles", "needles", "needles", "in", "here")
find.needle(haystack1) # 4
find.needle(haystack2) # error
find.needle(haystack3) # 3
find.needle(haystack3, needle="needles", ret=TRUE) # 3 5