(in-ns 'clojure.core)

(import '(java.io Writer OutputStream))

(defn lformat
  "Formats a string using java.lang.String.format in the locale.
  See java.util.Formatter for format string syntax."
  [loc fmt & args]
  (String/format loc fmt (to-array args)))

(defn slprintf
  "Prints formatted output in the locale to the stream."
  [strm loc fmt & args]
  (if (instance? Writer strm)
	(.write strm (apply lformat loc fmt args))
	(.print strm (apply lformat loc fmt args))))
  
(defmacro sprintf
  "Prints formatted output to the stream."
  [strm fmt & args]
  `(slprintf ~strm (java.util.Locale/getDefault) ~fmt ~@args))
