code-reviews

girish 2019-08-18T14:34:49.035300Z

cross posting from #clojurescript Complete clojure/cljs newbie, bootstrapped a project with shadow-cljs to display latest artworks from behance https://github.com/girishso/xilop For some reason not able to get routing working.. tried using secretary/`accountant`… maybe i’m missing something obvious(?). Also, would appreciate any feedback on coding style/structure or anything that stands out to you.

tdantas 2019-08-18T16:40:31.036Z

hey guys, quick help I’m trying to implement my own flatten function using only loop recur

(defn my-own-flatten [tree]
  (loop [[h & t] tree
         result []]
     (cond
       (nil? h) result
       (coll? h) (recur h result)
       :else (recur t (conj result h)))))

tdantas 2019-08-18T16:41:41.036400Z

the code is not working as expected, can you guys give me a hand ?

tdantas 2019-08-18T16:54:39.036800Z

I’ve fixed my function what you guys think ?

(defn my-own-flatten [tree]
  (loop [[h & t] tree
         result []]
     (cond
       (nil? h) result
       (coll? h) (recur t (doall (concat result (my-own-flatten h))))
       :else (recur t (doall (concat result [h]))))))