|
|
|
|
|
by diggan
2238 days ago
|
|
Well, clojure.string/reverse is relying on StringBuilder so I guess you could call it not just Clojure but Clojure + Java really. Source for clojure.string/reverse is this: `(.toString (.reverse (StringBuilder. s))))` (The implementation of clojure.string/reverse) would only work on Clojure running on JVM. Clojure-clr, ClojureScript or any of the other ones, would use a difference implementation, not using StringBuilder. `(apply str (reverse s))` is then I guess "more" general across Clojure implementations. So Clojure is using StringBuilder, ClojureScript is using regexes + split to list + reverse + rejoin, ClojureCLR I'm not sure, but probably something C# specific. But in the end, that's all semantics and the point is moot. Since Clojure is a pragmatic language, using an already defined function is obviously better, so no reason why you wouldn't use clojure.string/reverse, all the Clojure implementations have it exposed already. |
|