I am going through some Clojure tutorials using Closure Box, and entered the following code:
user> (def stooges (vector "Moe" "Larry" "Curly"))
#'user/stooges
user> (contains? stooges "Moe")
false
Shouldn't this evaluate to TRUE ? Any help is appreciated.
contains? support Set, if you use clojure-1.4
A vector is similar to an array.
contains?
returnstrue
if thekey
exists in the collection. You should be looking for the "key/index" 0, 1 or 2If you were using a hash...
As mikera suggests, you probably want something like clojure.core/some
This is a common trap! I remember falling into this one when I was getting started with Clojure :-)
contains? checks whether the index (0, 1, 2, etc.) exists in the collection.
You probably want something like:
Or you can define your own version, something like: