Clojure

clojure.string/join doesn't work with sets and some other sequences

Details

  • Type: Defect Defect
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Completed
  • Affects Version/s: Release 1.2
  • Fix Version/s: None
  • Component/s: None
  • Labels:
    None
  • Patch:
    Code
  • Approval:
    Ok

Description

clojure.string/join function doesn't work with sets and java collections. This happens because the parameters destructuring is used, and for sets there is no 'nth' function defined that is required for destructuring.

I attached trivial patch that fixed this problem by using first/next functions instead of destructuring

Activity

Hide
Stuart Halloway added a comment -

Two possibilities here:

  • join requires a sequential thing, and set is not a sequence, so the current behavior is correct.
  • join can join any seq-able thing, and we should look at the patch.

Which is right?

Show
Stuart Halloway added a comment - Two possibilities here:
  • join requires a sequential thing, and set is not a sequence, so the current behavior is correct.
  • join can join any seq-able thing, and we should look at the patch.
Which is right?
Hide
Rich Hickey added a comment -

The doc says:

clojure.string/join
([coll] [separator [x & more]])
Returns a string of all elements in coll, separated by
an optional separator. Like Perl's join.

Could be more explicit about how coll will be used (e.g., "elements in coll, as returned by (seq coll)"), then # 2 could work. Also, the reference to Perl is not good, and should be unnecessary.

Show
Rich Hickey added a comment - The doc says: clojure.string/join ([coll] [separator [x & more]]) Returns a string of all elements in coll, separated by an optional separator. Like Perl's join. Could be more explicit about how coll will be used (e.g., "elements in coll, as returned by (seq coll)"), then # 2 could work. Also, the reference to Perl is not good, and should be unnecessary.
Hide
Stuart Halloway added a comment -

12/17 patch is good, and updates doc string to match semantics.

Show
Stuart Halloway added a comment - 12/17 patch is good, and updates doc string to match semantics.

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: