code-reviews

Stas Makarov 2020-07-24T14:12:08.188Z

Hi! I'm making an app for a local non-profit organization which helps homeless people ( http://homeless.ru ). This is pro-bono work. It's a small reagent SPA which talks with their CRM via an API. This is my first kinda real Clojure[script] project, so I'll be very grateful for any tips on improving the code. Most of the code is here: https://github.com/jehaby/mks/blob/humaid/shared/humaid/src/main/humaid/app.cljs

1❤️
jaihindhreddy 2020-07-24T22:25:17.188900Z

As you said, interleave works too, but it looks a bit more awkward to my eyes:

(defn expr->where-clause [attrs from to]
  (let [syms (->> #(symbol (str "?" (gensym)))
                  (repeatedly (dec (count attrs))))]
    (->> (conj (vec syms) to)
         (interleave attrs)
         (cons from)
         (partition 3 2))))

2020-07-24T23:34:59.189200Z

@jaihindhreddy nice. That's fairly clean. I tried and failed to get parition and interleave to get this to work. i think i was relying on the padding and not cons the from.

2020-07-24T23:36:13.189400Z

@smith.adriane thanks for the review. i cleaned it up based on this then went another direction using reduce then ponged back to what jaihindhreedy has there. 2 hours of fiddling. 🙂

1🙂