I'm trying to use << from clojure.contrib.strint perform string interpolation in a string variable. The following,
(ns strint-test (:use clojure.contrib.strint)) (def v 1) (println (<< "v: ~{v}")) (def s "v: ~{v}") (println (<< (str s))) (println (<< s)) results in v: 1 v: ~{v} java.lang.RuntimeException: java.lang.RuntimeException: java.lang.IllegalArgumentException: No matching method found: indexOf for class clojure.lang.Symbol (strint-test.clj:8) Does anybody have any advice on getting (<< s) to work? I have included the << macro and associated function from clojure.contrib.strint for reference. Thanks. (defmacro << [string] `(str ~@(interpolate string))) (defn- interpolate "Yields a seq of Strings and read forms." ([s atom?] (lazy-seq (if-let [[form rest] (silent-read (subs s (if atom? 2 1)))] (cons form (interpolate (if atom? (subs rest 1) rest))) (cons (subs s 0 2) (interpolate (subs s 2)))))) ([^String s] (if-let [start (->> ["~{" "~("] (map #(.indexOf s %)) (remove #(== -1 %)) sort first)] (lazy-seq (cons (subs s 0 start) (interpolate (subs s start) (= \{ (.charAt s (inc start)))))) [s]))) -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en