These kinds of collections can be nice, but I think it’s fair to warn against looking at them too closely. Sometimes they’re not actually idiomatic and often the implementations have differences in them that see non-obvious.
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.
> Create string t containing the same characters as string s, in reverse order. Original string s must remain unaltered. Each character must be handled correctly regardless its number of bytes in memory.
What encoding? Assuming UTF-8, what is a "character"? A code point? A grapheme? The result of the lack of specification is that the different approaches really solve different problems. Some, like the C implementation, have a naive approach that only solves the problem in fixed size encodings where the width is equal to CHAR_BIT. Others I'm sure run into problems with combining characters
This improves time when learning 1 language to another. I could get lost spending time here advancing what I already know (or don't know) and enjoy the format of the content here.
What was your process like in going about getting the original content for the various languages? Are you you somewhat familiar with all these languages and how to the curators go about accepting (or denying) a new submission.
Author here: there were 2 initial use cases for me,
(1) I'm familiar with the language X but I forget e.g. how to "check if a file exists"
(2) I'm learning a new language Y, I know that "checking if a file exists" is a legit need and there must be an idiomatic way to do it in Y, so I look at the entry, alongside implementations in other languages that I'm more familiar with, so I can quickly spot the similitudes and the differences.
I do (1) all the time because my brain has very little onboard memory.
The website is open to contributions without prior validations. This means that not all snippets end up being both correct and idiomatic. I manually revert spam and "obviously incorrect" entries. For languages that I don't know very well, I encourage actual experts to fix snippets, or add a better new implementation, when they see poor contents.
This is really cool and seems pretty up-to-date ... which leaves me surprised that Obj-C is present but Swift isn't. (Even moreso considering that both Java and Kotlin are present).