beginners

Getting started with Clojure/ClojureScript? Welcome! Also try: https://ask.clojure.org. Check out resources at https://gist.github.com/yogthos/be323be0361c589570a6da4ccc85f58f.
sova-soars-the-sora 2020-12-13T01:42:55.113900Z

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-sora 2020-12-13T01:44:56.114100Z

maybe my lein is just out of date?

sova-soars-the-sora 2020-12-13T01:47:30.114300Z

Oh thank heavens

sova-soars-the-sora 2020-12-13T01:47:33.114500Z

that was it

sova-soars-the-sora 2020-12-13T02:03:51.114800Z

talk about adrenaline...

yiorgos 2020-12-13T10:47:49.118300Z

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

yiorgos 2020-12-13T11:19:07.119300Z

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

futurile 2020-12-13T11:22:30.120100Z

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

st3fan 2020-12-13T14:27:14.120500Z

Same for me

2020-12-13T18:46:52.124400Z

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.

2020-12-13T18:48:50.127300Z

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.

v3ga 2020-12-13T18:49:27.128300Z

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

👍 1
dorab 2020-12-13T19:01:26.128500Z

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

👍 2
2020-12-13T19:23:57.129Z

Thank you both!

yiorgos 2020-12-13T20:50:17.132700Z

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

borkdude 2020-12-13T20:57:55.133100Z

@g3o (keys the-map)

borkdude 2020-12-13T20:58:06.133500Z

this is how you will get to the keys.

dpsutton 2020-12-13T20:58:23.134100Z

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

dpsutton 2020-12-13T20:59:18.136100Z

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

yiorgos 2020-12-13T21:00:15.136900Z

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

borkdude 2020-12-13T21:00:40.137500Z

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

dpsutton 2020-12-13T21:00:54.138200Z

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

clyfe 2020-12-13T21:01:17.138800Z

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

yiorgos 2020-12-13T21:01:33.140400Z

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

borkdude 2020-12-13T21:01:37.140800Z

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

yiorgos 2020-12-13T21:01:39.141Z

but it seems not 🙂

dpsutton 2020-12-13T21:02:09.142200Z

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

yiorgos 2020-12-13T21:02:20.142500Z

I think seq is quite good for my case

yiorgos 2020-12-13T21:02:33.142800Z

Thanks guys for your help!!

clyfe 2020-12-13T21:03:35.142900Z

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

dpsutton 2020-12-13T21:06:11.143800Z

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

yiorgos 2020-12-13T21:07:20.144100Z

I am just trying to solve some 4clojure problems

Brandon Olivier 2020-12-13T23:25:45.145500Z

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.

dpsutton 2020-12-13T23:30:58.148900Z

You could use #(every? Identity %)

Brandon Olivier 2020-12-13T23:52:06.152400Z

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