This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
- # aws-lambda (5)
- # beginners (38)
- # boot (197)
- # carry (7)
- # clara (3)
- # cljs-dev (7)
- # cljsjs (6)
- # cljsrn (24)
- # clojure (39)
- # clojure-art (10)
- # clojure-austin (7)
- # clojure-dusseldorf (1)
- # clojure-italy (8)
- # clojure-russia (89)
- # clojure-spec (119)
- # clojure-taiwan (1)
- # clojure-uk (19)
- # clojurescript (104)
- # community-development (2)
- # conf-proposals (22)
- # copenhagen-clojurians (8)
- # cursive (2)
- # datomic (35)
- # devcards (4)
- # dirac (79)
- # euroclojure (2)
- # immutant (35)
- # om (138)
- # om-next (2)
- # onyx (172)
- # proton (4)
- # protorepl (1)
- # re-frame (36)
- # reagent (34)
- # spacemacs (1)
- # specter (7)
- # untangled (89)
- # yada (2)
how do i get the index of current item in
for while iterating the vector of maps?
@olegakbarov I don't think
for has this feature, you may want to use
one more thing: does this looks like idiomatic way to rearrange items in vector?
(defn rearrange [arr a b] "a and b are both indexes and arr is vector" (let [item-a (nth arr a) item-b (nth arr b) b4-a (subvec arr 0 a) btwn (subvec arr (+ a 1) b) aftr-b (subvec arr (+ b 1))] (concat b4-a btwn [item-b] [item-a] aftr-b)))
@olegakbarov seems ok, you should consider that it does not return a vector, and AFAICT it will still hold a reference to the old vector
if i wrap it into
into  does it looses reference ? is it better in terms of performance?
@olegakbarov into is eager so yes, it will loose reference. It's not generally better in terms of performance, it depends on the use case. Using concat and subvec makes current implementation return a (lazy) sequence very fast, but it will not support random access reads, and traversing it may be slower than traversing a vector.
I usually make an implementation that works and avoid worrying about the performance until necessary 🙂
@olegakbarov You could use the :fn part to make sure the invariant a < b is enforced by spec: http://clojure.org/guides/spec#_spec_ing_functions
I have a map that I thread through a number of functions like this:
As a next step I'd like to use
(-> my-map (foo params) (bar params) (baz (repeatedly 10 some-fn))) ;; I’d like to use apply on baz here
applyto add a number of params to baz:
(defn baz [mymap & args]). What is the best way to achieve that? Thanks!
(-> my-map (foo params) (bar params) (as-> xs (apply (partial baz xs) (repeatedly 10 some-fn)))
as->today! Big thanks!
Hey plp, I have very basic notions of clojure, but I want to focus more on clojurescript. What would be the best path given these premises.
personally I really liked using reframe as a starting point to clojurescript (but at the time I knew some clojure TBH)
the difference is, if you know clojure or clojurescript you know like 95% of the other language
hmm @sveri , good to know, so the best source to learn currently would be clojurescript unraveled?
@marciol I dont know what the best source for learning clojurescript is. I started both at the same time and learning clojure I was able to write cljs anyway
great, I will focus more on clojurescript side, given that my backend development currently is focused on RoR. Eventually I will use clojure in backend side too, but for while the clojurescript is the current target.