I want to write a program in clojure
that would return only the first index value of true
values from my function. My code goes here:
(defn func [f x] (map f x))
So, if I give a value like:
(func zero? [1 1 1 0 3 7 0 2])
It gives me:
(false false false true false false true false)
and if I give:
(func (fn [n] (= n 6)) [:cat :dog :six :blorg 6])
It returns:
(false false false false true)
But, what I want is index value
of first true
. Like for
(func zero? [1 1 1 0 3 7 0 2]) => 3 (desired result)
(func (fn [n] (= n 6)) [:cat :dog :six :blorg 6]) => 4 (desired result)
(func zero? [1 1 3 7 2]) => nil (desired result)
Can anybody suggest how to get the first index
value of true
?