This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-08-11
Channels
- # architecture (11)
- # bangalore-clj (1)
- # beginners (42)
- # boot (28)
- # chestnut (1)
- # cider (1)
- # cljs-dev (28)
- # cljsrn (7)
- # clojure (124)
- # clojure-austin (1)
- # clojure-italy (10)
- # clojure-russia (3)
- # clojure-spec (29)
- # clojure-uk (32)
- # clojurescript (62)
- # core-async (22)
- # data-science (7)
- # datascript (5)
- # datomic (8)
- # events (1)
- # fulcro (15)
- # funcool (1)
- # jobs (1)
- # keechma (10)
- # lein-figwheel (4)
- # lumo (4)
- # mental-health (1)
- # off-topic (21)
- # om (10)
- # onyx (8)
- # parinfer (29)
- # pedestal (1)
- # planck (4)
- # portkey (2)
- # protorepl (1)
- # random (1)
- # re-frame (12)
- # ring (3)
- # spacemacs (6)
- # uncomplicate (63)
anyone have pointers on where to look for having clojurescript set the browser url? Prob just plain js, but not obvious. maybe just .location?
@stvnmllr2 (set! (.-location js/window) s)
@noisesmith ok, thanks for the code even. Didn't know if anyone had a better way. Guess I'll just pass in my secretary generated URL and i'll be good.
Anybody ever see a situation where you have code like
(apply merge-with some-collection)
oops hit return too early
Anybody see a situation where you have code like
(defn merge-function [a b] ...)
(apply merge-with merge-function some-collection-of-maps)
and you get an ArityException for merge-function getting only one arg?Can you provide a concrete example?
Here's the whole function I'm dealing with:
(defn merge-ratings [col]
(let [merge-function (fn [a b]
(let [a-ratings (:ratings a)
a-must-take (:must-take a-ratings)
a-student-path (:student-path a-ratings)
a-demand (:demand a-ratings)
b-ratings (:ratings b)
b-must-take (:must-take b-ratings)
b-student-path (:student-path b-ratings)
b-demand (:demand b-ratings)]
(update-in a [:ratings] #(do {:must-take (or a-must-take
b-must-take)
:student-path (or a-student-path
b-student-path)
:demand (max (or a-demand 0)
(or b-demand 0))}))))]
(->> col
(map #(do {(:course-key %) %}))
(apply merge-with merge-function)
(apply merge-with merge-function)
vals)))
It breaks on this:
(def merge-rating-test
[{:prefix "PSY",
:number "201",
:credits 4.0,
:title "Gen Psychology*SSC",
:course-key :PSY201,
:ratings {:must-take nil, :student-path true, :demand 1.0}}
{:prefix "PSY",
:number "201",
:credits 4.0,
:title "Gen Psychology*SSC",
:course-key :PSY201,
:ratings {:must-take true, :student-path nil, :demand 2.0}}
{:prefix "PSY",
:number "201",
:credits 4.0,
:title "Gen Psychology*SSC",
:course-key :PSY201,
:ratings {:must-take nil, :student-path nil, :demand 3.0}}])
(merge-ratings merge-ratings-test)
Hmm... didn't see that second merge line... I don't think that was always there. Let me fix that and try again.
Fixed it. Still breaks.
(defn merge-ratings [col]
(let [merge-function (fn [a b]
(let [a-ratings (:ratings a)
a-must-take (:must-take a-ratings)
a-student-path (:student-path a-ratings)
a-demand (:demand a-ratings)
b-ratings (:ratings b)
b-must-take (:must-take b-ratings)
b-student-path (:student-path b-ratings)
b-demand (:demand b-ratings)]
(update-in a [:ratings] #(do {:must-take (or a-must-take
b-must-take)
:student-path (or a-student-path
b-student-path)
:demand (max (or a-demand 0)
(or b-demand 0))}))))]
(->> col
(map #(do {(:course-key %) %}))
(apply merge-with merge-function)
vals)))
The weird thing is, when I changed (apply merge-with merge-function)
with (apply merge-with list)
it did exactly what I'd expect and output a list of the two values.
I think it's that #(do ...
lambda. it expects parameters.
That was it. Fixed it. Sorry for the trouble
I have a form in my clojurescript that looks like this:
(.remove this/classList "playing")
this === node
in javascript it would be this.classList.remove(//...)
When I write it like this, it works, but the clojurescript setup I have yells at me when I save, and it auot-reloads, saying "No such namespace: this, could not locate this.cljs, this.cljc, or JavaScript source providing ""
perhaps I am accessing the remove
method incorrectly?
Use the this-as macro: (this-as this (.remove (.-classList this) "playing"))
(I may not have nailed the .-classList part)
sorry, I was using that...this is the whole code block:
(defn handle-remove-transition [e]
(this-as this
(when (= (.-propertyName e) "transform")
(.remove this/classList "playing"))))
sorry, let me give that a try
amazing!
true, I feel that one is more readable
it ends up being about preference, yes?
actually -> works in place of .. there
+cljs.user=> (-> #js{:a 0} .-a inc)
1
oh, the difference is the .