在 clojure 中应用 str 时保留空格
我正在尝试将 [\space \space \space \a \space]
之类的 vec 减少到
" a "
但是,我得到:
Clojure> (apply str [\space \space \space \a])
" a "
看来 str 正在剥离多个 \space 字符。有办法解决这个问题吗?
(顺便说一下,我只是使用 尝试 Clojure 来尝试并完成 4clojure)
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)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为这是 tryclj 问题,而不是 clojure 问题。
刚刚在 clojure 1.2 上测试
UPD:
我几乎可以肯定这是 tryclj 标记问题。刚刚在tryclj上测试过
I think its tryclj issue, not clojure.
Just tested on clojure 1.2
UPD:
I'm almost sure that is tryclj markup issue. Just tested on tryclj
这不是 clojure 问题,只是 HTML 问题: 如果我写:
这会呈现为 abc,因为 HTML 会折叠空格(请随意检查这个问题的来源 - 我确实在两个实例中都写了很多空格)。您的 repl 位于 HTML 环境中,因此如果得知在一两个地方它对于转义
块不够小心,我不会感到太惊讶。
It's not a clojure issue, just an HTML issue: If I write:
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.