This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-03-13
Channels
- # announcements (4)
- # babashka (1)
- # beginners (124)
- # calva (5)
- # cider (3)
- # clara (3)
- # clerk (5)
- # clj-commons (14)
- # cljdoc (12)
- # cljs-dev (14)
- # clojure (43)
- # clojure-austin (23)
- # clojure-europe (55)
- # clojure-nl (1)
- # clojure-norway (11)
- # clojure-uk (2)
- # clojurescript (34)
- # conjure (1)
- # cursive (1)
- # data-science (28)
- # datomic (3)
- # fulcro (20)
- # gratitude (2)
- # hyperfiddle (6)
- # introduce-yourself (1)
- # jobs (5)
- # lsp (56)
- # malli (5)
- # membrane (7)
- # mount (5)
- # off-topic (16)
- # polylith (39)
- # portal (38)
- # practicalli (1)
- # rdf (1)
- # re-frame (8)
- # releases (8)
- # remote-jobs (4)
- # shadow-cljs (49)
- # sql (1)
- # xtdb (36)
hello, can I ask something? The calculation codes are working as I wanted. But I want to change that code more simply and readable. So I defined a function to call calculations. But when I call the function but that doesn't work. Why? Can anyone help me?
Prefix VS Infix notation.
In, say, python you’d write s * w / h * h
– *in*fix
In Clojure: (/ (* s w) (* h h))
– *pre*fix
See, in Python /
and *
are operators. And they have the famous operator precedence rules (PEMDAS).
s * w / h * h
works because multiplication has precedence over division. This is hard to remember and get right.
Lisps (like Clojure) are simpler:
• /
and *
are just functions
• The first elements in a list ( … )
is considered a function to be called. -> no need for operator precedence.
Ops that's a very basic mistake, thank you so much. Still my brain works like java python-dev 🙂
Please call (e/watch ...)
only once per atom and share the return value. Otherwise, each individual watch will trigger separately, causing extra wasteful computation and also causing your app to see inconsistent states ("reaction glitch")
The same applies to swap!, it is better to modify the atom "as a transaction", like this:
(def !state (atom {}))
; bad - each swap! will cause your app to update
(swap! !state assoc :a 1)
(swap! !state assoc :b 2)
(swap! !state assoc :c 3)
; good - one transaction = one update
(swap! !state assoc :a 1 :b 2 :c 3)
(swap! !state #(merge % {:a 1 :b 2 :c 3}))
(swap! !state merge {:a 1 :b 2 :c 3})
(swap! !state #(-> %
(assoc :a 1) ; composable updates
(assoc :b 2)
(assoc :c 3)))
Breaking change in master: hf/*http-request*
is now e/*http-request*
, https://github.com/hyperfiddle/electric/commit/9f6f1679bd0fd14761424cfbd4e2a65b61cced61#diff-e2cf315a7c2fe086e9d235b2596d161efa8e91722ea6b2ed7f3abeaf9db81587