Fork me on GitHub
devn01:09:08 Any suggestions on making this cleaner? I put together a multimethod version which dispatches on (:type node) but I know there’s a cleaner way to do this.


(defn hoist-maps [[n & rst] m]
  (when n
    (let [n (if (vector? n) (first n) n)
          top-level (medley/map-keys (fn [k] (kwds/kwd n "." k)) m)]
      (if rst
        (let [descend (first rst)
              [child-key option] (if (vector? descend) descend [descend])
              children (get m child-key)]
          (if (or (seq children) (not= option :optional))
            (map (fn [sub] (merge top-level sub))
                 (mapcat (partial hoist-maps rst)

😫 3

(hoist-maps [:incidents :claims :transactions]
              {:name "bob jones"
               :claims [{:category "hurt"
                         :thing "foot"
                         :transactions [{:amount 1}
                                        {:amount 2}
                                        {:amount -3}]}
                        {:category "emotional"`
                         :thing "tired"}]})


ah, i missed that yours could have more "top level" versions


It is just a recursive for


I assume you’re right, but I don’t follow. 😞


((fn f [lst node]
   (let [typed-node (and (map? node)
                         (contains? node :id)
                         (contains? node :type))
         lst' (if typed-node node lst)]
     ((if (and lst typed-node)
        #(cons {:from (:type lst) :from-id (:id lst) :to (:type node) :to-id (:id node)} %)
      (for [a (if (map? node) (vals node) node)
            :when (coll? a)
            i (f lst' a)]
 {:id   "A"
  :type "A"
  :foo  [{:type "B"
          :id   "B"}
         {:type "C"
          :id   "C"
          :bars {:these {:data nil}
                 :keys  {:data {:type "D"
                                :id   "D"}}
                 :are   {:data []}
                 :not   {:data {:type "Q"
                                :id   "Q"}}}}
         {:type "E"
          :id   "E"
          :bars {:guaranteed {:data {:type "F"
                                     :id   "F"}}}}
         {:type "G"
          :id   "G"
          :bars {:to-be-uniform {:data {:type "H"
                                        :id   "H"}}}}]})


i was screwing with

(let [m {:id 1
         :type "A"
         :relationships [{:id 2
                          :type "B"}
                         {:id 3
                          :type "C"
                          :anyting {:data {:id 4
                                           :type "D"}}}]}
      id (:id m)
      type (:type m)]
  (for [vs (vals m)
        :when (coll? vs)
        v vs]
    {:from-id id
     :from-type type
     :to-id (:id v)
     :to-type (:type v)}))


but that only got me one layer in


im going to have to stare at this for a bit


i did something very similar to this recently


Hi, I have been using clojure/core.match in my code, and while building uberjar I am getting File name too long . Does anybody here has been hit by the same issue before and what can be done to fix the issue ?


@aman.shah5673 How are you building the uberjar?


Also, what O/S are you on?


@seancorfield lein uberjar and OS is ubuntu 18.04


Hmm, then I'm a bit surprised about that.


I have heard of that coming up with core.match because of the way some of its macros behave. This issue is related, although doesn't mention core.match:

Norman Eckstein07:09:27

I’m almost getting a crisis 😑 vacation ends Sunday and on Monday I have to do C# again at work.

😬 9

sneak in some F#

👍 6
Norman Eckstein08:09:13

That’s what I’m working on since 1.5 years (Talking about the many benefits of F# - in a . NET environment / infrastructure) and now I have one colleague who’s interested but all other people there - don’t understand the benefits and don’t want it.

Norman Eckstein08:09:05

I got told C# is what has to be done, period.


I have the same problem on my current work (java)


don’t know what I can do about that


show it’s better, they say


but it’s not like I have a lot of time to rewrite systems in clj to show how better it is when there are stupid java bugs to fix

👍 3
Adam Helins09:09:25

Small thing, but I have been using the following simple convention when dealing with plural names. As humans we are tempted to rely on English but it is consistently inconsistent when programming (see debates on naming SQL tables, datum Vs data, and so one). Reminiscent of regexes, why not append '+' to a singular name in order to designate a collection ? entity+ instead of entities ? Easy and consistent. However, it might get tricky when exchanging data across langs.


why not entity*? + implies 1 or more, while s / * usually means 0 or more


anyway, I’m fine with a little bit of ambiguity, I know the language :D

Adam Helins09:09:46

Indeed, but * already holds different meanings in Clojure


I think both + and * are bit too overloaded. Personally I prefer pluralising using the English grammar rules and when that is impossible (singular or plural are identical or when using a word from another language) I just append “-items” to the singular word. Readability is more important than character count or regularity IMO. Besides, having one simple rule for words that can’t be pluralised isn’t that irregular anyway ;)

👍 9
Gleb Posobin13:09:45

What are the possible reasons for using #'x instead of x? Looking at the reagent template that luminus generates and it is using the former. Yet changing it to the latter keeps the code working.

Alex Miller (Clojure team)13:09:15

the former is a var and will "see" changes if the var is rebound during the life of the server

Gleb Posobin13:09:40

Ah, if I do (def x) in repl?

Alex Miller (Clojure team)13:09:44

so the former lets you modify your code, with the server running, and immediately see those changes

Alex Miller (Clojure team)13:09:25

x is var which is a box holding a value. #'x is a reference to the box

Gleb Posobin13:09:31

I see, makes sense! Thank you.

Alex Miller (Clojure team)13:09:44

x will be evaluated to the value inside the box

Alex Miller (Clojure team)13:09:55

if you invoke #'x and x holds a function, it invokes the function. this is slower but more dynamic.

Gleb Posobin13:09:37

Yeah, I have been using defn instead of def to do that before, haha, didn't know there is a better way.

Alex Miller (Clojure team)13:09:39

no difference either way

Alex Miller (Clojure team)13:09:14

defn is essentially just def fn - the difference here is in how you refer to x

Gleb Posobin14:09:00

How do I get the value inside the var if I have #'x?

Alex Miller (Clojure team)14:09:37

you can deref it - @#'x

Gleb Posobin14:09:07

I see, and if x is a function, (#'x) will just do (@#'x) for me?

Norman Eckstein14:09:31

That @alexmiller is investing his precious time to explain things that you could learn yourself by reading a book. 👍:skin-tone-2:


@info902 i think that came off a little rude. understanding the subtleties of vars can be quite tricky and its a natural question. the question was completely appropriate for the channel and i'm happy to have followed along on the discussion.

Norman Eckstein14:09:52

Sorry 😐 I’m not a native speaker

Norman Eckstein14:09:43

Perhaps I’ve chosen the wrong words


no worries. most everything can be learned from a book. but sometimes its hard to know which concept you need to look up.

Alex Miller (Clojure team)14:09:51

yeah, I'm capable of deciding how to spend my time, thanks :)

😁 6
Michael W14:09:13

I thought he meant he thought it was cool that alex would take the time instead of just saying RTFM.

👍 3
Norman Eckstein14:09:59

I have two books of?/by Alex on my desk

Norman Eckstein14:09:06

Its sad that there are not more Clojure jobs out in the wild, especially in Germany.


where are you based?

Norman Eckstein14:09:21

Germany Heidelberg/ Mannheim

Norman Eckstein14:09:51

You are making your face a secret Las 😉


Heidelberg is a beautiful city!


So jealous. Wish I could be there this time of year especially.

Mark Gerard15:09:27

I agree, been to Sinsheim and I loved how green it was.

Norman Eckstein15:09:35

I'm sure the local authorities are happy about all new StartUp founders who will settle there 😎


Might seriously consider depending on how the next election cycle goes 😬


on I found in Berlin (checks map…learns it’s a 6 hour drive from Heldelberg)


@info902 There are #jobs #jobs-discuss #jobs-remote and a few other jobs related channels here, that might help you find ideas or approaches that have worked for others

👍 3
Norman Eckstein16:09:12

@U0E11941M that’s already at the order edge of my country 😄

Norman Eckstein14:09:03

Right now I can only learn & practice in my spare time.


Same in Switzerland 😞


(i apologize for misreading @info902)

Norman Eckstein14:09:20

As I have a family and cant move I need to start my own side project in Clojure

Norman Eckstein14:09:24

@dpsutton its okay, I have to work on my English skills

Norman Eckstein14:09:23

There is a #business channel but zero activity? I wonder why ? Clojure is the perfect programming language for Startups...

Alex Miller (Clojure team)14:09:45

they're too busy :)

👍 9
Norman Eckstein14:09:11

The only right answer 😝


(bind [m {:a 3}
       #{a} m] 

😮 3

sometimes i feel like i go too far


I… uh…