Clojure-Contrib

java-utils/as-str could be variadic

Details

  • Type: Defect Defect
  • Status: Closed Closed
  • Resolution: Completed
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: None
  • Labels:
    None

Description

Compojure has a function called str* that works like clojure.core/str but uses the names of symbols/keywords instead of their literal representation.

clojure.contrib.java-utils/as-str fulfills the same purpose, but only accepts a single argument.

as-str could be 100% compatible with str if it became variadic:

(defn as-str
  [& args]
  (apply str (map (fn [x] (if (instance? clojure.lang.Named x)
                            (name x) x))
                  args)))

user> (as-str "Hello, " :World)
"Hello, World"

Activity

Hide
Assembla Importer added a comment -
Show
Assembla Importer added a comment - Converted from http://www.assembla.com/spaces/clojure/tickets/18
Hide
Assembla Importer added a comment -

stuart.sierra said: (In revision:5dbecc380cbb65afff33648325f1e3b44b535143) java_utils.clj: made as-str variadic like str, fixes #18

This commit also includes tests for this function.

Branch: master

Show
Assembla Importer added a comment - stuart.sierra said: (In revision:5dbecc380cbb65afff33648325f1e3b44b535143) java_utils.clj: made as-str variadic like str, fixes #18 This commit also includes tests for this function. Branch: master

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: