Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Solution to problem 29 does not pass #59

Open
huylv opened this issue Apr 20, 2022 · 3 comments
Open

Solution to problem 29 does not pass #59

huylv opened this issue Apr 20, 2022 · 3 comments

Comments

@huylv
Copy link

huylv commented Apr 20, 2022

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?

@borkdude
Copy link
Collaborator

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.

@oxalorg
Copy link
Owner

oxalorg commented Apr 20, 2022

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.

@borkdude
Copy link
Collaborator

Agreed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants