Fork me on GitHub
#beginners
<
2017-10-03
>
bwstearns00:10:27

Does anyone have expertise with the clojure.data.zip.xml library?

bwstearns00:10:10

I’m running into an issue with xml-zip/xml-> on nested repeated tags (i.e. <a><a>FOO</a></a><a><a>BAR</a></a>) returning all the results as a list of one element.

boogie66612:10:02

has anyone else had problems with cider? eval-ing anything throws "java.lang.IllegalAccessError: with-safe-transport does not exist"

boogie66612:10:19

@bwstearns does xml-zip/xml-> work with something like <a>FOO</a><a>BAR</a> ?

boogie66612:10:43

i'm expecting to not work with that either 😛 since xml needs a root node

dpsutton12:10:14

there is a workaround of putting a sleep into the startup

boogie66613:10:48

i saw in the thread, but... i have no clue where to do that...

dpsutton13:10:14

how familiar with emacs are you and are you running a standard emacs or spacemacs?

boogie66613:10:32

and not at all 🙂

dpsutton13:10:53

ok. so we want to visit the function they talk about

dpsutton13:10:53

(defun cider--connected-handler ()
  (let ((cider-enlighten-mode nil))
    (cider-make-connection-default (current-buffer))
    (cider-repl-init (current-buffer))
    (cider--check-required-nrepl-version)
    (cider--check-clojure-version-supported)
    (cider--check-middleware-compatibility)
    (cider--subscribe-repl-to-server-out)
    (when cider-auto-mode
      (cider-enable-on-existing-clojure-buffers))
    (sleep-for 0.1) ;; <-- Increase timeout till it works 
    (cider--debug-init-connection)
    (run-hooks 'cider-connected-hook)))

dpsutton13:10:17

there's a command called find-function that we want to run

dpsutton13:10:33

do you know how to run interactive commands in spacemacs?

dpsutton13:10:43

M-x in vanilla emacs, no idea in spacemacs

boogie66613:10:53

SPC SPC does that 😛 the cider--connected-handler is not there

dpsutton13:10:31

ok. let's navigate to your packages folder. we need to edit cider.el

boogie66613:10:35

(spc spc does M-x)

dpsutton13:10:46

cider must not be loaded right now

dpsutton13:10:59

oh ps, let's head to #cider so we don't spam this channel

bwstearns13:10:48

It was actually a bug with the library. I wish I had started looking into that possibility sooner but it's never the library lol.

danny22:10:04

is there a short way of defining this function that takes two words, converts to lower-case then compares them for match?

(defn same? [w cw] (= (str/lower-case w) (str/lower-case cw)))

noisesmith22:10:18

I don’t think the shorter versions would be better, but if we’re golfing here’s my go

(def same? #(apply = (map str/lower-case %&)))

noisesmith22:10:47

or, maybe more useful (defn equal-by [f] (comp (partial apply =) (partial map f) vector)) then (def same? (equal-by str/lower-case))

noisesmith22:10:17

at least that way there’s an abstraction that makes some kind of sense backing up the terseness

danny22:10:57

@noisesmith thanks! Should have been a little clearer, wasn't necessarily trying for golf, more so just still new to the lang and a lot of times I find out later there's some core function that makes things simpler

noisesmith22:10:19

fair enough, nothing specific for this case

noisesmith22:10:07

unless you are frequently comparing things based on some pre-processing function, your original is likely the best way to do it

danny22:10:04

Gotcha, this is just a practice problem for http://exercism.io, so I guess I'll stick with the original 😉

athomasoriginal23:10:53

Lets say I am hitting my head against a wall trying to get a filter function to work. I really want to see what it is looping over each time, would the best way to debug this be using a doseq?

athomasoriginal23:10:25

My thought process is that I can't do side effects in filter but I can inside of doseq - printing each line is the side effect - to sum up: what is the best way to debug filter

eggsyntax23:10:54

@tkjone I’d start by calling the predicate function on some individual values, from the REPL. If you need to dig deeper than that (eg if the predicate is really complicated), it’s a great candidate for running in a debugger.

eggsyntax23:10:44

eg if I’m doing (filter even? (range 5)), I’d start in the repl by calling (even? 0), (even? 1), etc, until the behavior is totally clear.

eggsyntax23:10:33

Also you can definitely cause side effects from within filter. eg you could do (filter #(do (println %) (even? %)) (range 5))

athomasoriginal23:10:40

ahhhh! Very nice, thank you! Forgot about do