This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-08-25
Channels
- # announcements (4)
- # asami (26)
- # babashka (82)
- # beginners (27)
- # biff (6)
- # boot (1)
- # calva (42)
- # cider (2)
- # clj-commons (1)
- # clj-http-lite (2)
- # clj-kondo (37)
- # cljdoc (1)
- # clojure (46)
- # clojure-europe (34)
- # clojure-nl (1)
- # clojure-norway (7)
- # clojure-uk (2)
- # clojurescript (54)
- # code-reviews (18)
- # cursive (2)
- # datalevin (32)
- # datomic (7)
- # etaoin (1)
- # fulcro (9)
- # gratitude (3)
- # hyperfiddle (15)
- # introduce-yourself (1)
- # jobs (2)
- # lsp (32)
- # nrepl (1)
- # off-topic (18)
- # pathom (17)
- # pedestal (5)
- # polylith (89)
- # reitit (7)
- # releases (3)
- # remote-jobs (4)
- # shadow-cljs (52)
- # spacemacs (3)
- # squint (14)
- # tools-build (10)
- # tools-deps (18)
- # vim (4)
- # xtdb (34)
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]]}
if we have inpu variables as
(def input-var {:a :b :c [[:p true]
[:w false]
[:p false]]})
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?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.
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
[delta]
(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
[delta]
(swap! elapsed #(+ % delta))
(set! (.-x sprite) (+ 100 (js/Math.cos (/ @elapsed 50.0)) 100))))))
Working example from the docs:
<script>
// Create the application helper and add its render target to the page
let app = new PIXI.Application({ width: 640, height: 360 });
document.body.appendChild(app.view);
// Create the sprite and add it to the stage
let sprite = PIXI.Sprite.from('sample.png');
app.stage.addChild(sprite);
// 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;
});
</script>
Alright, I made it work by putting .add in front
(.add game.ticker
(fn
[delta]
(js/console.log delta)
(swap! elapsed #(+ % delta))
(set! (.-x sprite) (+ 100 (js/Math.cos (/ @elapsed 50.0)) 100))))))
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)
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
From the channel description: https://gist.github.com/yogthos/be323be0361c589570a6da4ccc85f58f
Thank you š looks like it has everything in the links provided, if not will surely get back to the clojure slack channels