4ever-clojure icon indicating copy to clipboard operation
4ever-clojure copied to clipboard

Solution to problem 29 does not pass

Open huylv opened this issue 3 years ago • 3 comments

Here is my solution to problem 29 - Get the Caps:

(fn [s] (apply str (filter #(<= (int \A) (int %) (int \Z)) s)))

Although it is even listed in the Solution page, it does not pass any test. Is this a bug?

huylv avatar Apr 20 '22 10:04 huylv

This is due to a difference in platform. Code in 4ever-clojure runs in JS and it behaves differently than the JVM:

user=> (int \A)
0
user=> (int \a)
0

The way you can do it in JS:

(.charCodeAt \a 0) ;;=> 97

@oxalorg We could patch SCI's int when invoked on a string to adapt to this, but I'm not sure it's a good idea.

borkdude avatar Apr 20 '22 11:04 borkdude

Yes I think changing the behavior of int doesn't feel right. Then we're neither completely true to Clojure nor completely true to Clojurescript and we're somewhere in between which makes me a bit uncomfortable.

I think it was a little different with format because goog.format is widely available and used, and we just aliased it to core.format.

I think it's fine that 4ever clojure is based on ClojureScript and somethings will fail from previous solutions. I'd rather just have a warning or a link to cheatsheet for clj->cljs.

oxalorg avatar Apr 20 '22 12:04 oxalorg

Agreed.

borkdude avatar Apr 20 '22 13:04 borkdude