Fork me on GitHub

I have a map as below , and if I want to update key :w and :p to true from the value of aj, How can i achieve it ?

(def aj [[:w false]
         [:p false]])

(def input-var {:a :b :c [[:p true]

after applying aj to input result will be as below 

(def result {:a :b :c [[:p true]
                    [:w true]
                    [:p true]]})


I assumed you would want to actually use the vals from aj so you'd use something like this:

(update input-var :c #(apply conj % aj))
;; => {:a :b, :c [[:p true] [:w false] [:p false]]}
but if you really want all vals to be true, you could do this:
(update input-var :c (fn [c] (reduce-kv (fn [acc _ [k _]] (conj acc [k true])) c aj)))
;; => {:a :b, :c [[:p true] [:w true] [:p true]]}


hmmm similar I wanted , but how to update as true


what do you mean by "update as true"?


[:w true]
[:p true]
instead of false


doesn't my second suggestion do that?


oh yeah! one more question

šŸ‘ 1

if we have inpu variables as

(def input-var {:a :b :c [[:p true]
                          [:w false]
                          [:p false]]})


how can I update in specific vector index /


you mean like this:

(assoc-in input-var [:c 1 1] true)
;; => {:a :b, :c [[:p true] [:w true] [:p false]]}
? I think this is the same question you asked on Monday, no?


yeah, but I have a collection now a input


ok got that šŸ™‚ (assoc m t [k true])

šŸ‘ 1

Are there any tools for viewing very large EDN files?


vscode lets me expand/collapse forms


Yes, but it will probably choke if you give it an EDN file that's 5 - 10mb.


Ah alright. I've opened huge xml files in vim


You can open that size file in Emacs but it eats memory like crazy and TBH Iā€™d rarely do it and only in fundamental mode not Clojure mode.


I'd try to tap> the EDN into #portal


In clojurescript I call a function of a library and the function complains that the this is not there. What should I do? Uncaught TypeError: Cannot read properties of null (reading '_addListener') Code of the called function:

Ticker.prototype.add = function (fn, context, priority) {
        if (priority === void 0) { priority = UPDATE_PRIORITY.NORMAL; }
        return this._addListener(new TickerListener(fn, context, priority));
The cljs that calls the function:
(game.ticker.add (fn
                       (swap! elapsed #(+ % delta))
                       (set! (.-x sprite) (+ 100 (js/Math.cos (/ @elapsed 50.0)) 100))))


All the code:

(defn init
  (let [game (js/PIXI.Application. (clj->js {:width 640, :height 360}))
        sprite (js/PIXI.Sprite.from "a.jpg")
        elapsed (atom 0.0)]
    (reset! app game) 
    (js/document.body.appendChild game.view)

    (game.ticker.add (fn
                       (swap! elapsed #(+ % delta))
                       (set! (.-x sprite) (+ 100 (js/Math.cos (/ @elapsed 50.0)) 100))))))


Working example from the docs:

      // Create the application helper and add its render target to the page
      let app = new PIXI.Application({ width: 640, height: 360 });

      // Create the sprite and add it to the stage
      let sprite = PIXI.Sprite.from('sample.png');

      // Add a ticker callback to move the sprite back and forth
      let elapsed = 0.0;
      app.ticker.add((delta) => {
        elapsed += delta;
        sprite.x = 100.0 + Math.cos(elapsed/50.0) * 100.0;


Alright, I made it work by putting .add in front

(.add game.ticker
            (js/console.log delta)
            (swap! elapsed #(+ % delta))
            (set! (.-x sprite) (+ 100 (js/Math.cos (/ @elapsed 50.0)) 100))))))

Muhammad Hamza Chippa15:08:33

I am getting the vector of maps from the re-frame and editing it using event although it is being changed on dispatching the event but the component is re-rendering. How can I solve this bug ?

(map (fn [model]
               [model-card-component ^{:key (:__Id__ model)} model]) @models)

vikas chinchansur23:08:55

Hello All šŸ‘‹, I am new to this Clojure Forum/community, an experienced Java programmer. At my work we are planning to use Clojure as backend programming language for one of our projects. It would be great if anyone can help with finding good online tutorials/courses to learn Clojure basics, which includes web development project as well. Thanks in advance. Cheers, Vikas


Should have everything you need and a bit more, and welcome to the repl life

vikas chinchansur00:08:04

Thank you šŸ™‚ looks like it has everything in the links provided, if not will surely get back to the clojure slack channels