Fork me on GitHub
#squint
<
2022-08-30
>
borkdude07:08:15

Wait a minute. I think it's better after all to use {} instead of js/Map here, since JS kind of does the right thing with {} for group-by-ish use cases:

$ ./node_cli.js -e '(prn (get (assoc {} [1 2 3] 4) [1 2 3]))'
4

vs

$ ./node_cli.js -e '(prn (get (assoc (js/Map.) [1 2 3] 4) [1 2 3]))'

borkdude07:08:18

it stringifies the key when storing and also when looking up, so you won't hit the mutability reference-based equality stuff when quering for composite stuff

didibus03:09:37

Maybe I'm too used to (verb noun) and how Clojure works, but:

(canvas.save)
   (canvas.translate x y)
   (canvas.rotate (/ (* t Math/PI) 2))
   (canvas.fillRect -100 -100 200 200)
   (canvas.restore))
Why not:
(doto canvas
  (save)
  (translate x y)
  (rotate (/ (* t Math/PI) 2))
  (fillRect -100 -100 200 200)
  (restore))
Is that not supported by Clavascript?

borkdude04:09:59

Yes, that is supported. I just literally translated one of their examples

👍 1