Fork me on GitHub
#beginners
<
2020-12-13
>
sova-soars-the-sora01:12:55

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)

sova-soars-the-sora01:12:56

maybe my lein is just out of date?

sova-soars-the-sora02:12:51

talk about adrenaline...

yiorgos10:12:49

Is anyone else has trouble to access http://4clojure.com

yiorgos11:12:07

Okay, I managed to visit the page using Firefox but Safari can’t open it for some weird reason.

futurile11:12:30

I can get there in Firefox, sorry no Safari. Sounds odd!

st3fan14:12:14

Same for me

andarp18:12:52

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.

andarp18:12:50

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.

v3ga18:12:27

Use a repl. I can’t imagine lisp without. That’s the big IT feature in my book.

👍 3
dorab19:12:26

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

👍 6
andarp19:12:57

Thank you both!

v3ga19:12:38

Np, one you use the REPL you’ll see. You work in tiny blocks of logic then once something works you physically place that logic where you want it. That’s the power of lisp to me.

👍 6
clyfe21:12:17

@U01GZD00HA8 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.

clyfe21:12:35

Also, use an editor-integrated REPL, not a terminal one.

yiorgos20:12:17

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

borkdude20:12:55

@g3o (keys the-map)

borkdude20:12:06

this is how you will get to the keys.

dpsutton20:12:23

You can call seq on the map to get it as a sequence of key value pairs and restructure that

dpsutton20:12:18

That would let you get the values but I would think there’s a better way to approach this perhaps

yiorgos21:12:15

I mean inside a let block something like (let [{:keys [these keys are unknown} map} return the vals here)

borkdude21:12:40

if you don't know the names, how will you refer to them?

dpsutton21:12:54

(let [[[k1 v1][k2 v2]] (seq {:a 1 :b 2})] [v1 v2])

yiorgos21:12:33

I was wondering if Clojure destructuring has something like that and I am not aware of it

borkdude21:12:37

Then why not just call vals 🤷 . I don't understand the use case.

yiorgos21:12:39

but it seems not 🙂

dpsutton21:12:09

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

yiorgos21:12:20

I think seq is quite good for my case

yiorgos21:12:33

Thanks guys for your help!!

dpsutton21:12:11

Just call vals to get the values as a seq if you don’t need their keys. Not sure what your use case is

yiorgos21:12:20

I am just trying to solve some 4clojure problems

Brandon Olivier23:12:45

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.

dpsutton23:12:58

You could use #(every? Identity %)

Brandon Olivier23:12:06

Thanks I ended up just reducing it differently to solve the same problem 🙂