3

I'm trying to reduce a vec like [\space \space \space \a \space] to

"   a "

However, I'm getting:

Clojure> (apply str [\space \space \space \a])
         " a "

It seems str is stripping multiple \space chars. Is there a way to get around this?

(By the way, I'm just using Try Clojure to try and work through 4clojure)

2 Answers 2

7

I think its tryclj issue, not clojure. Just tested on clojure 1.2

(apply str [\space \space \space \a]) => "   a"

UPD: I'm almost sure that is tryclj markup issue. Just tested on tryclj

(= (apply str [\space \space \a]) " a") => false
(= (apply str [\space \space \a]) "  a") => true
1
  • +1 from a Clojure 1.2.1 user. Don't know if the behavior has changed in 1.3.
    – ponzao
    Feb 15, 2012 at 9:20
5

It's not a clojure issue, just an HTML issue: If I write:

a      b       c

That renders as just a b c because HTML collapses whitespace (feel free to check the source of this question - I really wrote lots of spaces in both instances). Your repl is in an HTML environment, so I wouldn't be too surprised to learn that in one or two places it isn't careful enough about escaping <code> blocks.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.