Re: create vector from other vector and indices

2018-02-13 Thread Matching Socks
user> (def v [:a :b :c :d]) #'user/v user> (mapv v [3 1 2 0]) [:d :b :c :a] -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be pati

Re: create vector from other vector and indices

2018-02-13 Thread Tomasz Sulej
Or even simpler: (map v idx) On 13 February 2018 at 20:48, Tomasz Sulej wrote: > (map #(v %) idx) > > or > > (map (partial get v) idx)) > > On 13 February 2018 at 20:10, Andre Bieler > wrote: > >> Just started with clojure. >> Lets say I have two vectors, v containing values and another vector

Re: create vector from other vector and indices

2018-02-13 Thread Tomasz Sulej
(map #(v %) idx) or (map (partial get v) idx)) On 13 February 2018 at 20:10, Andre Bieler wrote: > Just started with clojure. > Lets say I have two vectors, v containing values and another vector idx > that contains the indices by which vector v should be ordered (rather a new > vector be crea

create vector from other vector and indices

2018-02-13 Thread Andre Bieler
Just started with clojure. Lets say I have two vectors, v containing values and another vector idx that contains the indices by which vector v should be ordered (rather a new vector be created, ordered given by idx. (def v [10, 11, 12, 13]) (def idx [1 3 0 2]) ; goal is a new vector with values