Fork me on GitHub
Vincent Cantin06:02:11

What is the difference between (defn ^:private my-fn ...) and (defn- my-fn ...) ? Both of them can be found in clojure.core. For example:


@vincent.cantin no difference. Possibly some functions were moved around after the definition of the defn- macro over time


@vincent.cantin It doubles up on the reduced since the reduce call a few lines down in cat needs to know if it was stopped by reduced


If so, it needs to return the reduced object (not the value it holds) since the transduction needs to stop.


hi there, im trying to use lein from the command line


but it gets stuck ... can't even do lein new poject_name ..


Could not transfer artifact lein-ancient:lein-ancient:jar:0.6.10 from/to maven-public .. interesting


lein help does work?


im trying.. i think it tries to connect to a cached repo


ok, so now it works


i'm looking at the A* implementation in the joy of clojure. I'm trying to understand why the algorithm does not step forwards and backwards between, say, [0 0] and [0 1]

Vincent Cantin10:02:39

Does it exist a transducer equivalent of tree-seq ?

Vincent Cantin18:02:35

I made a transducer version of tree-seq which seems a lot faster than the original and the improved POC on github.

Vincent Cantin18:02:02

Transducers really rocks!


nice one 🙂


Think i got it. When the algorithm is working on [0 1], it will add [0 0] as a new work item when [0 0] is checked again, the algorithm will look up the neighbors of [0 0], trying to find the cheapest path to get to [0 0]. It will compute a newcost, which will inevitably be higher than the existing cost to get to that position, hence the todo list does not grow. this prevents an infinite loop


What says the clojure-community about ORM? Especially Rich...


Rich is not a fan of ORMs, neither is most of the community


thank you sir, jazakaLLahu hoir


Could this be destructured: `(fn [dims] (let [dimensions (js->clj dims :keywordize-keys true) width (:width dimensions) height (:height dimensions)]` I only want to keep width and height.


(let [{:keys [width height]} (js->clj ... should work.


Width and height at extracted after conversion not before

Reuben Steenekamp14:02:30

Hello all. I'm struggling to include :npm-deps {:rmwc "1.2.0"} into my build. It claims to not be able to find react, even when I include cljsjs/react in my dependencies.

Compiling ClojureScript...
• js/dashboard.js
• js/devcards.js
      throw er; // Unhandled 'error' event
Error: Cannot find module 'react' from '<redacted>/node_modules/rmwc/Button'


:npm-deps is still a bit buggy I believe, depending on the library. You include react also with :nmp-deps?

Reuben Steenekamp15:02:12

I tried, but then it complains that it cannot find module './ReactInternal'.

Reuben Steenekamp15:02:03

All I want is a Material UI library that I can easily use. react-mdl is deprecated, material-ui pulls in it's own react and react-dom (which isn't too bad but I want to avoid it) and rmwc isn't on cljsjs. Any other suggestions?


you might want to ask in #clojurescript


@reuben.steenekamp I’m just starting to look at material-ui — and it looks like material-ui-next - doesn’t pull it’s own but uses 16.0. Where did you see material-ui pulls in own react and react-dom?

Reuben Steenekamp16:02:16

I mean't from cljsjs From

cljsjs/material-ui comes with its own cljsjs/react and cljsjs/react-dom.


@reuben.steenekamp one thing to note: shadow-cljs has a mechanism to deal with the fact that many libraries import from cljsjs. it basically shims them so you can install from npm


@reuben.steenekamp Got it - with shadow-cljs this wouldn’t be an issue.


@reuben.steenekamp if you are going to be importing a lot of javascript libraries i’d strongly consider using shadow-cljs, which makes this stuff easier because you just install using npm or yarn. but if you want to get it working using the normal clojure compiler, you will need to import using :foreign-libs


this is how I got react-dnd to work

:foreign-libs [{:file "resources/lib/ReactDnD.js"
                :file-min "lib/ReactDnD.min.js"
                :provides ["react-dnd"]}]


before i moved to shadow i just copied the UMD build from the /dist directory of the node_module into my source tree and then pointed the compiler to it using a :foreign-libs like the above

Reuben Steenekamp16:02:15

Cool, I hadn't heard about shadow-cljs, will check it out.


Alohaa, another question for Reframe. How do I access a value in the state just once, without subscribing to it? Is this possible or is it totally the wrong approach?


For example I have a list of Users in the State which I want to go through in the frontend, to see if it contains a certain value. I just want to do that once when I press a button for example, without rerendering everything.


similar way in React would be “MapStateToProps” and the i can access them easily

Drew Verlee21:02:42

can anyone think of a more straight forward way to build up hashmap? (def board (zipmap (range 1 9) (repeat {:player-id nil})))


as always, there's a way to do it with for if you prefer (into {} (for [n (range 1 9)] [n {:player-id nil}]))


I have an app that I’m currently storing some state inside of an agent, and I would like to update the data inside of that agent once a day


is there a library or idiom for doing something like that?


@lilactown you don't need a library -- one idiom is this:


(import '[java.util.concurrent

(defonce threadpool (delay (Executors/newScheduledThreadPool 1)))

(let [a (atom {})]
    (.scheduleAtFixedRate ^ScheduledExecutorService @threadpool
                          #(update-my-atom a)
                          0 ;; delay
                          refresh-interval TimeUnit/MINUTES)
 ;; return the atom


make the atom, pass it to a background function that is periodically called


there are many other ways to do it. can use a future that loops


I think the important distinction there is "once per day per process" or "once per day in the world" - scheduled thread pool works great for the former, for the latter you need some inter-process communication


yeah, per process


I prefer the scheduled thread pool because it gives you transparency and introspection that a future doesn't


I’m not familiar at all with the java threading/scheduling APIs - so it’s going to take me a bit to unpack this 😅


@lilactown the handy thing is that normal functions are callable - so you can just pass a function of 0 args to be executed


I'd read the docs on the ExecutorService and related classes. Very well designed


question coming from my naivete w/r/t web development: I'd like to serve multiple websites from one linux box with one IP address. Ideally, there'd be some Clojure way to do that. Let me know if there is! I think though I have to set up nginx or apache. What gives me pause is, to configure either of them, I have to specify where .html files are. I'm using clj-http and compojure. I'm not sure how much I have to change my clojure apps to accommodate what I want to do. Ideally, I could just point nginx to two different java processes for two different URLs. I doubt that's how it works, though!

Vincent Cantin18:02:35

I made a transducer version of tree-seq which seems a lot faster than the original and the improved POC on github.