1 minute read

Code kata

Problem

Write a function to determine if a vector contains a set of items.

Solution

(defn containsv [v & items]
  (some (set items) v))

Note

Using a set as the predicate supplied to some allows you to check whether any of the truthy values in the set are contained within the given sequence. This is a frequently used Clojure idiom for searching for containment within a sequence.

comments powered by Disqus