This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-09-29
Channels
- # beginners (42)
- # boot (12)
- # cider (3)
- # cljs-dev (277)
- # cljsrn (44)
- # clojure (127)
- # clojure-austin (9)
- # clojure-austria (1)
- # clojure-brasil (14)
- # clojure-canada (1)
- # clojure-dev (22)
- # clojure-dusseldorf (1)
- # clojure-italy (4)
- # clojure-russia (24)
- # clojure-spec (33)
- # clojure-taiwan (1)
- # clojure-uk (21)
- # clojure-ukraine (8)
- # clojurescript (134)
- # core-async (41)
- # core-logic (8)
- # cursive (1)
- # datomic (3)
- # ethereum (1)
- # events (4)
- # funcool (1)
- # leiningen (12)
- # off-topic (21)
- # om (19)
- # onyx (45)
- # overtone (1)
- # parinfer (2)
- # pedestal (3)
- # proton (2)
- # re-frame (103)
- # reagent (48)
- # test-check (27)
- # untangled (51)
- # vim (3)
@dorianc.b no, you are not forced to use clojurescript it's client side, you can use whatever you prefer what I did: - clojure for the server, to learn the language - javascript on the client to check that my server works as I want it to - now clojurescript on the client
when you see how powerful clojurescript and its ecosystem are, I guess you'll move to clojurescript as well 🙂
what regex can capture the word surrounded by another word (from either sides)... like: #"house (\w+) | (\w+) house"
I’m trying to write an algorithm for modified competition ranking (https://en.wikipedia.org/wiki/Ranking#Modified_competition_ranking_.28.221334.22_ranking.29) in clojure, but I’m not making any headway into something that would be elegant. How could I prevent lookups into previous map values?
Standard ranking is trivial (map-indexed (fn [idx itm] (conj itm {:rank (+ idx 1)})) leaderboard))
I think you might want a reducer here really. Because you need to "look back" as you build up, to check for equivalents.
Reduce looks like it might do what I want, but all the examples I find are extremely dissimilar to what I want to do. I can’t figure out the syntax, really.
It's a little hard to explain, essentially you have an "accumulator" and a "new item"
And each time the fn is called (with accumulator, and the next item from the list), you return a new value for the accumulator
(reduce
(fn [ld itm]
(let [last-item (last ld)
last-value (first last-item)
last-rank (:rank (last last-item))]
(if (= itm last-value)
(conj ld [itm {:rank last-rank}])
(conj ld [itm {:rank (inc (count ld))}]))))
[]
[1 2 2 4])
That does standard competition ranking. Doing modified ranking is a little more complex, plus I'll steal all the fun if I solve it for you 😉.
Modified ranking is slightly harder to implement, but not too difficult. There is probably a better way to do this, but reduce is what comes to mind. I'm sure someone will weight in with a one-liner at some point.
I’m pretty much in the beginning of my clojure learning and I’m learning about maps but I got this error. Is conj not applicable to maps?(conj {:b 2,:a 1} :c 3) IllegalArgumentException Don't know how to create ISeq from: clojure.lang.Keyword clojure.lang.RT.seqFrom (RT.java:542)
Yea just figured it out after I asked lol. Not much syntax but it’s a taking a bit to sink in
@dorianc.b The most common way to do it is to use assoc
, though: (assoc {:b 2 :a 1} :c 3)
thanks ill keep that in mind. I’m currently just going through the Clojure the brave book so I just started
App won’t build on heroku, need help quick:
-----> SSH app detected
-----> Installing ngrok... ! Push rejected, failed to compile SSH app.
! Push failed