Hey all,

I'm trying to build my clojure/clojurescript skill by porting this Facebook 
React code into Om: 
http://facebook.github.io/react/blog/2013/11/05/thinking-in-react.html

I trying to manipulate the products data structure functionally, instead of 
sequentially.

(def products
  [{:category "Sporting Goods" :price "$49.99" :stocked true :name "Football"}
   {:category "Sporting Goods" :price "$9.99" :stocked true :name "Baseball"}
   {:category "Sporting Goods" :price "$29.99" :stocked false :name 
"Basketball"}
   {:category "Electronics" :price "$99.99" :stocked true :name "iPod Touch" }
   {:category "Electronics" :price "$399.99" :stocked false :name "iPhone 5"}
   {:category "Electronics" :price "$199.99" :stocked true :name "Nexus 7"}])

(->> products
     (partition-by :category)
     (reduce (fn [memo x] 
               (conj memo [(distinct (map :category x)) x]))
             [])
     (map (fn [[category products]] 
            [(str "Category: " (first category))
             (map #(str "Product: " (:name %)) products)]))
     (flatten))

;; Clojure Result:
;; ("Category: Sporting Goods" "Product: Football" "Product: Baseball" 
"Product: Basketball" "Category: Electronics" "Product: iPod Touch" "Product: 
iPhone 5" "Product: Nexus 7")

;; Clojurescript Result:
;; (Category: Sporting Goods Product: Football Product: Baseball Product: 
Basketball Category: Electronics Product: iPod Touch Product: iPhone 5 Product: 
Nexus 7)

-------------

I'm wondering why Clojurescript is getting rid of the quotes? Is there a 
different between Clojure and Clojurescript that I'm missing?

Thanks!
-pr

-- 
Note that posts from new members are moderated - please be patient with your 
first post.
--- 
You received this message because you are subscribed to the Google Groups 
"ClojureScript" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/clojurescript.

Reply via email to