LoginSignup
1
1

More than 5 years have passed since last update.

Clojureで文字列を反転する

Last updated at Posted at 2012-11-17

文字列の反転にはreverseが使えけど、結果型がcharのシーケンスになってしまうので、繋げる必要がある。

(let 
  [rev-str (reverse "foobar")]
    (reduce str 
      (first rev-str) 
      (rest rev-str)))

もっと1発で繋げられる方法ないかな?


追記

tnoda_さんに情報頂きました

(apply str (reverse "foobar"))

もしくは、

(clojure.string/reverse "foobar")
1
1
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1