Like this? (defn printf+ [& [writer & more :as xs]] (if (instance? java.io.PrintWriter writer) (binding [*out* writer] (apply println more)) (apply println xs)))
On Sat, Dec 31, 2011 at 10:01 AM, Andy Fingerhut <andy.finger...@gmail.com>wrote: > I know I can bind *out* to another stream like *err*, but is that the only > way built-in to Clojure? > > (binding [*out* *err*] (println "This will go to *err*, not *out*")) > > If it is the only way, is there some library perhaps where someone has > implemented a function that lets you specify the output stream as an > argument, e.g. > > (printf+ *err* "This will go to *err*") > (printf+ "This will go to *out* as the default output stream") > > Thanks, > Andy > > -- > 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 -- Sam Ritchie, Twitter Inc 703.662.1337 @sritchie09 (Too brief? Here's why! http://emailcharter.org) -- 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