This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-07-14
Channels
- # aleph (3)
- # announcements (1)
- # babashka (36)
- # babashka-sci-dev (4)
- # beginners (62)
- # biff (2)
- # calva (13)
- # cider (4)
- # clj-kondo (6)
- # cljdoc (17)
- # clojure (142)
- # clojure-dev (6)
- # clojure-europe (62)
- # clojurescript (20)
- # core-async (26)
- # cursive (18)
- # data-oriented-programming (9)
- # data-science (1)
- # datahike (18)
- # events (4)
- # fulcro (4)
- # graalvm (2)
- # hyperfiddle (15)
- # interop (1)
- # jobs-discuss (8)
- # leiningen (2)
- # lsp (91)
- # malli (1)
- # missionary (11)
- # nbb (65)
- # off-topic (50)
- # practicalli (2)
- # programming-beginners (4)
- # re-frame (18)
- # remote-jobs (1)
- # shadow-cljs (53)
- # spacemacs (1)
- # specter (2)
- # sql (17)
- # tools-build (63)
- # web-security (1)
- # xtdb (15)
Good day everyone, I am new to Clojure, a complete beginner. I was wondering if there is a blueprint one can use to get in, I am beginning a new job but I am looking to start from the ground up. Like a complete beginner
A lot of people start with https://www.braveclojure.com/clojure-for-the-brave-and-true/
@U01M742UT8F much appreciated, thank you very much
Brave Clojure is good! Two additional recommendations. If you're going to use Visual Studio Code, the https://calva.io/getting-started/ guide is excellent. That will help you both with how to use the devlopment environment, and get you started writing some Clojure. See #calva for Calva / VSCode questions. Once you've been able to evaluate some Clojure, I'd check out https://clojure.org/guides/getting_started. Happy hacking!
@U03PG4VKZ7B, I see you. You legend.
thank you @U0AT6MBUL
Hi all, I’m trying to decode/decipher a solution to a problem I would want to solve a completely different way, Here is the topic I posted in the discussion section of the person’s blog: https://github.com/jmglov/jmglov.net/discussions/2
On this link: https://jmglov.net/blog/2022-07-06-hacking-blog-categories.html he goes about turning a list of maps containing sets (:categories) into a map of category as key and blog posts as values
When I would see such a challenge, my first thinking would turn to group-by
which I found out, fails pretty quickly
Then I would likely turn to reduce
and begin plowing through ways to ultimately get to the result I’m after
but his solution as seen above is so simple using mapcat with a function, after which an easy reduce solves it all
I totally get that you have to think about data transformation using functions and getting from A->B, but in this case I would rather quickly hit a road block
(for [{:keys [categories] :as post} sort-output category categories] [category post])
is the same thing has the mapcat with the nested map
and likely what I would write first, and then maybe pull apart into using map/mapcat/filter if I wanted to turn it into a transducer or something
i even tried to create a reduce fn with a sub loop/recur to walk through all category in categories, and failed
and to be fair, I didn't think through the problem, and come with for, I just happen to know that a map inside a mapcat is a for
i tend to stay away from (for , as when I first came to functional programming etc, it was all about unlearning manual looping mechanisms
writing a for is a lot like writing a sql query (I often end up mixing up when and where because for uses when and sql uses where)
I’m trying to understand how I can get it in my head that using (for might be a good idea for this kind of problem
you can think of each clause in a for as a nested mapping inside the mapping above it
Biggest difference with for
at one level deep is with multiple sequence bindings: you get cross product semantics for the two sequences, whereas with map
it's "zipping" the two together elementwise.
ok, so for is for building values in the sequence monad and let basically does the same thing for the identity monad
the vector approach is likely a little more efficient, it sort of breaks things down into small parts and rebuilds, and with the map approach you build a more complicated structure the same shape as the result you want, then merge them, where merging has to break down the more complicated structure again
thank you very much for your help, i’ve added an exercise for myself to try your apply merge-with into as well
(merge-with into
{"Lisp" ["Common Lisp" "Clojure"]
"ML" ["Caml" "Objective Caml"]}
{"Lisp" ["Scheme"]
"ML" ["Standard ML"]})
;;=> {"Lisp" ["Common Lisp" "Clojure" "Scheme"], "ML" ["Caml" "Objective Caml" "Standard ML"]}
ha, the first example from clojuredocs shows exactly what you are talking about