Fork me on GitHub
#beginners
<
2017-01-18
>
dragsubil10:01:22

Hello, I'm trying to do an exercise from the Brave and True book and I've written a function like this:

dragsubil10:01:38

clojure

(defn better-symmetrize-body-parts
  "Expects a seq of maps that have a :name and :size"
  [asym-body-parts]
  (reduce (fn [final-body-parts part]
            (into final-body-parts (set (into (into [] (matching-part part)) #{part}))))
          []
asym-body-parts))

dragsubil10:01:21

I'm wondering if there is a better way to write this as this looks a bit ugly

mavbozo10:01:10

@dragsubil what is the problem statement?

dragsubil10:01:26

To take asym-hobbit-body-parts (the vector of maps you see in the snippet), create new maps for "right", "top" and "bottom" for each map where :name starts with "left", and output a modified version of the vector with the new maps included

dragsubil10:01:01

You can see the expected output in the snippet

dragsubil11:01:38

@skadinyo Yours is much better. Thank you

madstap13:01:12

@dragsubil left-eye right-eye bottom-eye top-eye ? Is this The hobbit, by H P Lovecraft?

dragsubil13:01:38

@madstap 😅 I forgot I left hobbit in there

genec13:01:51

Beginners - I just found this great 1 click installer for a Clojure IDE https://sekao.net/nightcode/

mavbozo13:01:41

nightcode is really easy to install

lmergen14:01:31

okay, so i'm a complete REPL noob and trying to adopt the "reloaded" workflow, but it appears as if my REPL is pretty wonky... specifically, i made changes to a clojure file, and it doesn't seem to pick up on it, most of the time (sometimes it does pick up on the changes)

lmergen14:01:40

i'm trying to debug this issue, because i want to figure out what's going on

lmergen14:01:52

how can i best proceed ?

lmergen14:01:18

after issueing reset-all, it does claim to be reloading the module

lmergen14:01:38

but at least the code that's being executed is not updated

mavbozo14:01:10

@lmergen is your situation like this: a function a/foo in file a.clj calls function b/bar in file b.clj. then you make changes to b/bar body and calls reset-all to reload file b.clj but when you call a/foo, it still using old b/bar code

lmergen14:01:07

i have thought about that as well, but i have no idea how to debug this to figure out whether that's actually the case

lmergen14:01:41

for what it's worth, i've properly set the the reloaded.repl/set-init, and the function that's called there does not see the changes

lmergen15:01:16

what steps should i take to figure out more ?

lmergen15:01:41

i'm not sure, but perhaps this is a hint

user> (clojure.tools.namespace.repl/refresh)
:reloading (com.autheos.video.routes com.autheos.video.web-server com.autheos.video.system com.autheos.video.main user)
:ok
user> (clojure.tools.namespace.repl/refresh)
:reloading ()
:ok
user> 
as in, maybe my env directories aren't defined properly somewhere ?

lmergen15:01:52

i do set the set-refresh-dirs properly

mavbozo15:01:05

after the first call to refresh and the second call to refresh, did you change those files?

mavbozo15:01:10

if no files changes then c.t.n.r/refresh reload nothing

mavbozo15:01:20

i'm sorry, i've made a wrong question earlier. should be "after the first call to refresh and before second call to refresh, did you edit those files?"

lmergen15:01:07

yeah i understand what you meant

lmergen15:01:14

i guess i should start back from scratch

lmergen15:01:21

and work my way back up from there

lmergen15:01:31

(fwiw, i'm basing my things around juxt' edge repo now)

skadinyo15:01:55

Maybe autosave feature in your text editor or ide?

lmergen15:01:36

nah, i'm fairly confident this is more complex an issue

lmergen15:01:29

it's working now

mavbozo15:01:36

@lmergen lmergen, i assumed you use clojure.tools.namespace directly. i just saw juxt's edge repo and it uses reloaded.repl which uses c.t.namespace

lmergen15:01:48

@mavbozo correct, is that a problem ?

mavbozo15:01:00

hard to say, juxt's edge repo uses boot and reloaded.repl which I never use. When I started learning to use reloaded workflow, I created a blank project with lein new app my-reloaded and use the guide in clojure.tools.namespace readme.

lmergen15:01:01

like i said, i think i need to go back to the drawing board and make things "simple" again 🙂

lmergen15:01:08

and start from scratch

mavbozo15:01:19

oh, this leiningen template from the creator of c.t.namespace helps me a lot to understand how to structure my project with reloaded workflow https://github.com/stuartsierra/reloaded

dominicm16:01:47

@lmergen set-refresh-dirs! doesn't work with boot/edge

lmergen16:01:35

@dominicm do you mean that that line where it's derived from the env doesn't work ?

lmergen16:01:41

because i'm hardcoding it at the moment

dominicm16:01:51

@lmergen hardcoding = bad, magic derivation = good.

dominicm16:01:11

(at least for boot)

lmergen16:01:16

yeah i know, this is in an attempt to debug my issues

dominicm16:01:40

It will prevent changes to those files from being read iirc.

dominicm16:01:06

Out of the box, the edge repo's reset does work, we use it on internal projects & so on.

dominicm16:01:29

I've only run into one issue, and it doesn't sound like you've hit that.

lmergen16:01:07

i'm not sure what it is

lmergen16:01:24

it's only triggered after i've been using the REPL for some while

lmergen16:01:56

i almost feel as if its triggered when something breaks during initialization / destruction of the component system

dominicm16:01:49

@lmergen does bouncing the repl fix the issue then?

lmergen17:01:11

@dominicm: to be honest, i'm not sure at this point. Usually restarting both the repl and emacs does the trick, but I'm still in the "I have no idea, let's poke it with a stick" phase

lmergen17:01:14

I was hoping to learn a bit more about how all this works, but looks like going back to scratch might be my best option..