This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-03-17
Channels
- # admin-announcements (4)
- # beginners (35)
- # boot (183)
- # cider (28)
- # cljs-dev (4)
- # cljsjs (1)
- # cljsrn (5)
- # clojure (52)
- # clojure-austin (4)
- # clojure-russia (83)
- # clojure-sdn (1)
- # clojure-uk (18)
- # clojurescript (48)
- # core-matrix (5)
- # cursive (4)
- # datomic (23)
- # devcards (2)
- # dirac (43)
- # editors (2)
- # emacs (4)
- # events (5)
- # funcool (2)
- # hoplon (81)
- # immutant (3)
- # juxt (3)
- # ldnclj (1)
- # luminus (12)
- # off-topic (6)
- # om (72)
- # onyx (32)
- # parinfer (2)
- # pedestal (1)
- # proton (6)
- # protorepl (3)
- # re-frame (30)
- # reagent (2)
- # spacemacs (2)
- # specter (1)
- # testing (1)
- # uncomplicate (3)
- # untangled (15)
- # yada (10)
ok, i'm confused. i need to map
, but at the same time, also keep track of a counter and increment it by one
what is the name of the function i'm looking for? or do i really need to start using recursion for this?
lmergen: a cool trick is (for [[i x] (map list (range) coll)] ...)
so you get the numeric index and the value for each item
d'oh, reading comprehension fail, you mentioned map not for as your first choice, right
yes, well, actually, i just need to iterate over a lazy sequence, apply a function with side effects on it, but i don't care about the results
oh, in that case use (dorun (map-indexed ...))
or (doseq [[i x] (map list (range) coll)] ...)
lmergen: it would totally be worth it to implement run-indexed!
- run! is like map but side effects only
=> (defn run-indexed! [f coll] (reduce (fn [i x] (f i x) (inc i)) 0 coll))
#'run-indexed!
=> (run-indexed! println [:a :b :c])
0 :a
1 :b
2 :c
3
is there some semi-standard filename where people put their "algorithms" or their own custom handy functions?
lmergen: there's user.clj I guess, but I think it's normal for a given dev or organization to have their own "util" lib that they habitually pull in
Design question. For internal application code, how do you decide between throwing an exception and returning error data, eg. {:error info}
?
codonnell: I do the compromise of the two, and I throw an instance of ex-info
being able to throw reduces the number of branches in the code, and it's nice to be able to keep the flow for unexceptional cases clearer
*visible branches - of course each throw is really a goto
I hadn't thought of it in terms of code flow. That's a really good point.
I think this is an interesting way of handling errors and exceptions also http://docs.caudate.me/hara/hara-event.html
not really sure if this is a 'beginners' topic, but... I'm trying to get a Clojure REPL in an existing Java/maven monolith project that leans heavily on Spring and AspectJ and ilk
wondering what pitfalls await me
so, there's a small set of classes that I want to interact with. They don't really need to be integrated with all this Spring/AspectJ nonsense
but I'm also trying to avoid having to pull them out into a separate artifact