Fork me on GitHub

Other than a for, how would I make this kind of nested mapping more elegant to look at?

(defn OpenSubtitles-parse [file-path]
   (let [root (-> file-path xml-reader zip/xml-zip)]
              (fn [el]
                     (fn [el] (map zip-xml/text (zip-xml/xml-> el :w)))
                     (zip-xml/xml-> el :s)))
              (zip-xml/xml-> root :document))}))

Michael Fiano01:04:27

By using threading macros


nah, just use for, it is great


or not, for would be better if you had mapcats in there


I'll see if thread-macroing it looks better..


Thanks πŸ™‚


I don't know that threading would be help there either


you might look at something like specter or a lense library, which would let you expression the transform in a more succinct way (not 100% sure about that)


This is the first time I'm using zip-xml, (or clojure's zippers at all), and it kind of begs something on top like specter, as it is kind of hard to read after being hacked together


Small humorous rant: 4 hours learning how to process huge XML files with clojure... Any idea why xml-zip is part of and not my ensuing code using xml zippers is barely readable in hindsight. I have found at par with Scala API πŸ™‚


@matan I sympathize. I've written just one XML parser with zippers and it was a mind-bending exercise. I still find the code fairly impenetrable.


@seancorfield any good game-plan for the next time around? I guess you don't parse XML much.. thanks for the sympathy anyway πŸ™‚


I try to avoid parsing XML at all costs 😞


you know... if you get one, you have to parse it


I'll try avoiding places where people hand over XML files..


I've never found a really elegant solution, in any technology.


If you're just looking for specific parts of an XML document, maybe Enlive would help? Since then you could use selector syntax to get at the parts you wanted...


But if you're trying to turn entire XML documents into data structures, there's not going to help you 😐


πŸ‘ Enlive it is, next time around


With specter, is there an easy way to reference another path in a transform?


paths are first-class, so you can do:

(def your-path
  (path ALL ALL :something))

(transform your-path f thing)
; combine many
(transform [:thing your-path ALL] f thing)


@matan I can recommend giving odin a spin,


Hey thanks @dominicm note taken


@dominicm that your idea of vacationing? 🌴 πŸ™‚


@matan Fiddling with my vim plugin & burning time on slack, what else is there in life?


I've used odin recently btw, it still works πŸ™‚


πŸ™‚ lol


You need to take real time off πŸ™‚


One day you will no longer be able to code, and it will all look more towards meaningless to you in hindsight, if you didn't leave time to do some other things


I'm kidding, don't worry. I very much appreciate that I need to take real time. I've barely touched my laptop this week, I spent 2 days in disneyland, and a bunch of time around that travelling there & back. I'm currently just killing some time waiting for my SO to get ready. I am trying to find new hobbies, learning Esperanto has been interesting.


πŸ™‚ enjoy your Esperanto!


For me, getting used to clojure syntax was enough language learning πŸ™‚ it has been more enticing than useful, as my coding velocity and productivity didn't experience a real surge switching to clojure, it just felt "pure" in a way


My brain was organized by switching to clojure, programming seems more transparent.


Me too. But productivity has not gone up. I think mainly to several factors: β€’ nils v.s. truthiness inconsistent in the language core API β€’ obscure to read code when using transducers, which are needed for stream processing and processing huge files β€’ chasing data shapes when refactoring code These all mean mediocre speed and productivity for me, so far. Even though I've become somewhat of an ace with functional programming. Community support is good though.


Anyway no commits over one year on master there..


How do I rewrite groovy -> clojure the following two lines ? groovy: the problem is that it is doing something with an ABSTRACT nested class, defined: I have already tried: ` (com.intellij.openapi.progress.Task$Modal. nil "string" true) ` I suspect the reason this is not working yet is because this is an abstract class, and I somehow have to override the function. Advice ?


Given clojure code is data and it is homoiconic and all of that, where are the code refactoring libraries for clojure hiding? πŸ™‚ I seem to hand-refactor too much these days... is there anything notable out there, for refactoring moves of sorts? I'm using proto-repl as my editor BTW, but wouldn't care going command-line for it πŸ™‚ I've only heard of slamhound, which does something very specific (I think).


rewrite-clj is the general purpose library.


hey thanks!!! you should find nicer vacation targets than Disney πŸ™‚


Is it used by some prominent IDE / tools too?


My girlfriend always wanted to visit, it's her 21st, special exception.


I think refactor.el uses it. Clj-refactor.nvim and light table uses the cljs fork.


what's an idiomatic way to conditionally cache a result of a function call, say depending on an environment? it feels like a use case for delay but my every attempt at creating condition seems to produce some code smell. my best so far is to create a get-fn that either invokes the function or derefs the delay, but I expect there's a better construct and/or ready-made function for it, just haven't found it


if you need more flexible caching (with eviction etc) take a look at


or if you need enterprise-grade πŸ˜„


I love these names, caffeine has never improved my memoization capability


what does a star at the end of a function parameter indicates?


@lockdown- If often indicates that the function is a primitive variant often meant to be used by a macro, or for use in building a non-starred version.


(Reading your question again, @lockdown- I see I misread and thought you were referring to a star at the end of a function’s name. I don’t know what a star at the end of a parameter name might indicate.)


yes, was referring to something like - but your answer taught something new anyway πŸ˜‰


in the try example, could it mean zero or more?


Oh, in that case it is regex


Hi all, I've just cloned this git repo:


I'm trying to run lein repl and then (in-ns 'hawk.core) but the directory structure is such that the .clj files are under src/main/clojure/hawk. I am guessing the structure is different to what I'm used to due to Java being in the repo too. Does anyone have any idea of how I can get to the hawk.core ns please?


Did you (require 'hawk.core) before the (in-ns 'hawk.core)?


that'll be it, cheers @dorab πŸ™‚


@schmee thanks I did take a look at memoize. I guess my issue was more with caching conditionally, which memoize doesn't seem to solve any better


hmm for conditional caching well I guess I could do (cond-> (get-fn) cache? memoize), that looks pretty enough


there are many ways to do it, a it/cond/case statement + memoize should do the trick


@kaosko Maybe look at core.cache or core.memoize and the examples in the docs around those? They rely on a through function to encapsulate the conditional logic.


(swap! my-cache core.cache/through-cache :some-key (fn [k] (code-to-produce-value k)))


@seancorfield thanks, yeah core.cache is good with proper eviction but have to stop overthinking this, especially since there was really no other reason but to try to make it prettier πŸ™‚


Ah, I hadn't scrolled far enough back to see the earlier comments about core.memoize, sorry! @kaosko