• (prefix-count aseq val)

0 Examples top

Log in to add / edit an example.

See Also top

Log in to add a see also.

Plus_12x12 Minus_12x12 Source clojure/contrib/pprint/utilities.clj:85 top

(defn prefix-count [aseq val]
  "Return the number of times that val occurs at the start of sequence aseq, 
if val is a seq itself, count the number of times any element of val occurs at the
beginning of aseq"
  (let [test (if (coll? val) (set val) #{val})]
    (loop [pos 0]
     (if (or (= pos (count aseq)) (not (test (nth aseq pos))))
       pos
       (recur (inc pos))))))
Vars in clojure.contrib.pprint.utilities/prefix-count: = count defn inc let loop not nth or test
Used in 0 other vars

Comments top

No comments for prefix-count. Log in to add a comment.