Fork me on GitHub
#beginners
<
2016-02-21
>
asier09:02:40

Hi all. I'm trying to draw a polygon on a map using CLJS but I have an issue with this piece of code.

lgastako10:02:10

Hi all… is there a macro that exists that is similar to the imaginary <- macro I’ve invoked below, or an easy way to write one, or a more idiomatic way of accomplishing the same thing?

val_waeselynck11:02:18

@lgastako: I think Prismatic did something like this in their Plumbing library

lgastako11:02:38

awesome, thanks.

mfikes15:02:04

That <- looks pretty cool. Without it, another couple ways are to use a fn

(->> [{:id 1 :data :x} {:id 2 :data :y}]
  (map (juxt :id identity))
  (into {})
  (#(get % 1)))
or to reach for the “big gun” as->:
(as-> [{:id 1 :data :x} {:id 2 :data :y}] x
  (map (juxt :id identity) x)
  (into {} x)
  (get x 1))

eggsyntax16:02:05

@lgastako: there's also the swiss-arrows lib, which has various generalizations & variations on the threading macros. The Trystero Furcula! The Parallel Diamond Fishing Rod! Fun stuff simple_smile https://github.com/rplevy/swiss-arrows

mariogintili18:02:36

hello peeps, I’m writing a function that given a list of elements returns a new one with the same elements in reverse order

mariogintili18:02:03

(defn recursive-reverse [coll]
  (loop [last-index (dec (count coll)) array (list)]
    (if (zero? last-index)
      (conj array (nth coll last-index))
    (recur (dec last-index) (conj array (nth coll last-index)))
    )
  )
)
is my code so far, but I’m getting ArityException Wrong number of args (0) passed to: PersistentVector but I can’t really tell where I’m making that error

mariogintili19:02:05

nvm got it sorted…gotta remember the difference between conj a list vs a vector

lgastako20:02:03

thanks @eggsyntax and @mfikes for the additional tips

josh.freckleton22:02:12

@mfikes: I haven't said thanks yet, so, thanks for helping me figure out the name-mangling issues with advanced compilation. I ended up using aget and changing the map to a vector since the indexes don't get mangled. Thanks!