Hi, I need some help, I broke my box. I'm not sure what's wrong. I tried to do a system upgrade and rebooted the server and re-running my application has this error
Exception in thread "main" java.lang.RuntimeException: java.lang.ClassCastException: class clojure.lang.PersistentVector cannot be cast to class clojure.lang.Named (clojure.lang.PersistentVector and clojure.lang.Named are in unnamed module of loader 'bootstrap') (NO_SOURCE_FILE:0)
maybe my lein is just out of date?
Oh thank heavens
that was it
talk about adrenaline...
Is anyone else has trouble to access http://4clojure.com
Okay, I managed to visit the page using Firefox but Safari can’t open it for some weird reason.
I can get there in Firefox, sorry no Safari. Sounds odd!
Same for me
As an experienced programmer with practically zero lisp experience I find it hard to grok Clojure code. I understand it fine when I read it, but when I look at code I get no intuitive feel for it - how it flows, what the intent of the writer was etc. No doubt this is in part something that simply comes with using the language and getting used to it, but I’d be curious to hear if any other beginners are having the same problems and how they have handled it.
Currently no, but I’m mostly in a reading phase of my learning... which I get isn’t an optimal way to get a language. Atm I have a lot more time to read than sitting at a computer to write.
Use a repl. I can’t imagine lisp without. That’s the big IT feature in my book.
I would second the advice to use the REPL. Especially when learning. You can try out small experiments and experience how Clojure works. You get immediate feedback. Totally short-circuits the write-compile-run-see_results cycle of non-REPL languages. If possible, set up your favorite editor and connect it to a REPL. Writing code in an editor helps immensely to balance parens and other formatting so that you can visually see the structure of the code. All editors connected to a REPL will have some hot-key combination to send each Clojure form to the REPL and evaluate it. You might find the following useful (if you haven't seen them already) https://clojure.org/guides/repl/introduction https://clojure.org/guides/repl/annex_community_resources
Thank you both!
is there a way to destruct a map with unknown key names? for example I know that a map has two key values but I don’t know the names
@g3o (keys the-map)
this is how you will get to the keys.
You can call seq on the map to get it as a sequence of key value pairs and restructure that
That would let you get the values but I would think there’s a better way to approach this perhaps
I mean inside a let
block something like (let [{:keys [these keys are unknown} map} return the vals here)
if you don't know the names, how will you refer to them?
(let [[[k1 v1][k2 v2]] (seq {:a 1 :b 2})] [v1 v2])
@anders152 What code do you read? Some of what people write in clj is ugg-lyy, so you have to pick your https://github.com/weavejester. 2nd'ly you need some familiarity with the https://blog.skyliner.io/fourteen-months-with-clojure-beb8b3e4bf00: update, cond->, etc.
I was wondering if Clojure destructuring has something like that and I am not aware of it
Then why not just call vals
🤷 . I don't understand the use case.
but it seems not 🙂
You could make your own macro to do such a thing though. Would be similar to what I just pasted but using the user supplied keys to bind to the values in an arbitrary order
I think seq
is quite good for my case
Thanks guys for your help!!
Also, use an editor-integrated REPL, not a terminal one.
Just call vals to get the values as a seq if you don’t need their keys. Not sure what your use case is
I am just trying to solve some 4clojure problems
What’s the function to use for f
in transduce
that would and
a seq of booleans? I tried and
, but I got an error that you can’t use a macro in that place.
You could use #(every? Identity %)
Thanks I ended up just reducing it differently to solve the same problem 🙂