• (dochars bindings & body)
bindings => [name string]

Repeatedly executes body, with name bound to each character in
string. Does NOT handle Unicode supplementary characters (above
U+FFFF).

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/string.clj:38 top

(defmacro dochars 
  "bindings => [name string]

  Repeatedly executes body, with name bound to each character in
  string.  Does NOT handle Unicode supplementary characters (above
  U+FFFF)."
  [bindings & body]
  (assert (vector bindings))
  (assert (= 2 (count bindings)))
  ;; This seems to be the fastest way to iterate over characters.
  `(let [^String s# ~(second bindings)]
     (dotimes [i# (.length s#)]
       (let [~(first bindings) (.charAt s# i#)]
         ~@body))))
Vars in clojure.contrib.string/dochars: = assert count defmacro first second vector apply concat dotimes hash-map let list seq with-meta
Used in 0 other vars

Comments top

No comments for dochars. Log in to add a comment.