Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Your example looks like Clojurescript? It is also inconsistent between variants?

  Clojure 1.11.3
  user=> (list? (cons 1 '(2 3)))
  false


Interesting! The tryclojure.org website says it's Clojure, not ClojureScript.

If it's inconsistent between variants then I'm absolutely not going to code in it...


It's not "inconsistent" between the variants. Clojure is a hosted language, it depends on the underlying platform.

In Clojurescript, the implementation details and type checks differ slightly from Clojure due to the different runtime environments (Javascript vs. JVM). As a result, certain predicates like `list?` might behave differently.

In Clojure, it's generally better to use (seq?) instead of (list?) when you need to check if a value is a sequence, as (seq?) is more encompassing and works for all sequence types, not just lists.

You almost never use (list?) in Clojure unless you explicitly need to check for a list created via (list ...), and most of the time we use (seq?) instead.

Maybe Clojure doesn't work for you because you haven't even bothered checking the documentation? At least you could've asked Google or ChatGPT, before crying how "broken it is". The language after all wasn't created last weekend, it's been around for 17 years




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: