Artwork

محتوای ارائه شده توسط Christoph Neumann and Nate Jones, Christoph Neumann, and Nate Jones. تمام محتوای پادکست شامل قسمت‌ها، گرافیک‌ها و توضیحات پادکست مستقیماً توسط Christoph Neumann and Nate Jones, Christoph Neumann, and Nate Jones یا شریک پلتفرم پادکست آن‌ها آپلود و ارائه می‌شوند. اگر فکر می‌کنید شخصی بدون اجازه شما از اثر دارای حق نسخه‌برداری شما استفاده می‌کند، می‌توانید روندی که در اینجا شرح داده شده است را دنبال کنید.https://fa.player.fm/legal
Player FM - برنامه پادکست
با برنامه Player FM !

Ep 051: Maps! Maps! Maps!

28:01
 
اشتراک گذاری
 

Manage episode 244666054 series 2463849
محتوای ارائه شده توسط Christoph Neumann and Nate Jones, Christoph Neumann, and Nate Jones. تمام محتوای پادکست شامل قسمت‌ها، گرافیک‌ها و توضیحات پادکست مستقیماً توسط Christoph Neumann and Nate Jones, Christoph Neumann, and Nate Jones یا شریک پلتفرم پادکست آن‌ها آپلود و ارائه می‌شوند. اگر فکر می‌کنید شخصی بدون اجازه شما از اثر دارای حق نسخه‌برداری شما استفاده می‌کند، می‌توانید روندی که در اینجا شرح داده شده است را دنبال کنید.https://fa.player.fm/legal

Each week, we discuss a different topic about Clojure and functional programming.

If you have a question you'd like us to discuss, tweet @clojuredesign, send an email to [email protected], or join the #clojuredesign-podcast channel on the Clojurians Slack.

This week, our topic is: "Maps! Maps! Maps!" We discuss maps and their useful features, including a key distinction that we couldn't live without.

Selected quotes:

  • "Working with Clojure makes you feel like you're living in the future!"
  • "Maps are bags of dimensions."
  • "The namespace of the key is the entity, the name is the attribute, and the value is the value."
  • "Flatter maps make it so you end up writing less code."

Related episodes:

Links:

Code sample:

;; Player records: one nested, one with rich keys.  (def players-nested  [{:player {:id 123  :name "Russell"  :position :point-guard}  :team {:id 432  :name "Durham Denizens"  :division :eastern}}  {:player {:id 124  :name "Frank"  :position :midfield}  :team {:id 432  :name "Durham Denizens"  :division :eastern}}])  (def players-rich  [{:player/id 123  :player/name "Russell"  :player/position :point-guard  :team/id 432  :team/name "Durham Denizens"  :team/division :eastern}  {:player/id 124  :player/name "Frank"  :player/position :midfield  :team/id 432  :team/name "Durham Denizens"  :team/division :eastern}])   ;; Extract player and team id, along with team name  ; Nested (defn extract  [player]  (let [{:keys [player team]} player]  {:player (select-keys player [:id])  :team (select-keys team [:id :name])}))  #_(map extract players-nested) ; ({:player {:id 123}, :team {:id 432, :name "Durham Denizens"}} ; {:player {:id 124}, :team {:id 432, :name "Durham Denizens"}})  ; Rich #_(map #(select-keys % [:player/id :team/id :team/name]) players-rich) ; ({:player/id 123, :team/id 432, :team/name "Durham Denizens"} ; {:player/id 124, :team/id 432, :team/name "Durham Denizens"})   ;; Sort by team name and then player name  ; Nested #_(sort-by (juxt #(-> % :team :name) #(-> % :player :name)) players-nested) ; ({:player {:id 124, :name "Frank", :position :midfield}, ; :team {:id 432, :name "Durham Denizens", :division :eastern}} ; {:player {:id 123, :name "Russell", :position :point-guard}, ; :team {:id 432, :name "Durham Denizens", :division :eastern}})  ; Rich #_(sort-by (juxt :team/name :player/name) players-rich) ; ({:player/id 124, ; :player/name "Frank", ; :player/position :midfield, ; :team/id 432, ; :team/name "Durham Denizens", ; :team/division :eastern} ; {:player/id 123, ; :player/name "Russell", ; :player/position :point-guard, ; :team/id 432, ; :team/name "Durham Denizens", ; :team/division :eastern})
  continue reading

118 قسمت

Artwork
iconاشتراک گذاری
 
Manage episode 244666054 series 2463849
محتوای ارائه شده توسط Christoph Neumann and Nate Jones, Christoph Neumann, and Nate Jones. تمام محتوای پادکست شامل قسمت‌ها، گرافیک‌ها و توضیحات پادکست مستقیماً توسط Christoph Neumann and Nate Jones, Christoph Neumann, and Nate Jones یا شریک پلتفرم پادکست آن‌ها آپلود و ارائه می‌شوند. اگر فکر می‌کنید شخصی بدون اجازه شما از اثر دارای حق نسخه‌برداری شما استفاده می‌کند، می‌توانید روندی که در اینجا شرح داده شده است را دنبال کنید.https://fa.player.fm/legal

Each week, we discuss a different topic about Clojure and functional programming.

If you have a question you'd like us to discuss, tweet @clojuredesign, send an email to [email protected], or join the #clojuredesign-podcast channel on the Clojurians Slack.

This week, our topic is: "Maps! Maps! Maps!" We discuss maps and their useful features, including a key distinction that we couldn't live without.

Selected quotes:

  • "Working with Clojure makes you feel like you're living in the future!"
  • "Maps are bags of dimensions."
  • "The namespace of the key is the entity, the name is the attribute, and the value is the value."
  • "Flatter maps make it so you end up writing less code."

Related episodes:

Links:

Code sample:

;; Player records: one nested, one with rich keys.  (def players-nested  [{:player {:id 123  :name "Russell"  :position :point-guard}  :team {:id 432  :name "Durham Denizens"  :division :eastern}}  {:player {:id 124  :name "Frank"  :position :midfield}  :team {:id 432  :name "Durham Denizens"  :division :eastern}}])  (def players-rich  [{:player/id 123  :player/name "Russell"  :player/position :point-guard  :team/id 432  :team/name "Durham Denizens"  :team/division :eastern}  {:player/id 124  :player/name "Frank"  :player/position :midfield  :team/id 432  :team/name "Durham Denizens"  :team/division :eastern}])   ;; Extract player and team id, along with team name  ; Nested (defn extract  [player]  (let [{:keys [player team]} player]  {:player (select-keys player [:id])  :team (select-keys team [:id :name])}))  #_(map extract players-nested) ; ({:player {:id 123}, :team {:id 432, :name "Durham Denizens"}} ; {:player {:id 124}, :team {:id 432, :name "Durham Denizens"}})  ; Rich #_(map #(select-keys % [:player/id :team/id :team/name]) players-rich) ; ({:player/id 123, :team/id 432, :team/name "Durham Denizens"} ; {:player/id 124, :team/id 432, :team/name "Durham Denizens"})   ;; Sort by team name and then player name  ; Nested #_(sort-by (juxt #(-> % :team :name) #(-> % :player :name)) players-nested) ; ({:player {:id 124, :name "Frank", :position :midfield}, ; :team {:id 432, :name "Durham Denizens", :division :eastern}} ; {:player {:id 123, :name "Russell", :position :point-guard}, ; :team {:id 432, :name "Durham Denizens", :division :eastern}})  ; Rich #_(sort-by (juxt :team/name :player/name) players-rich) ; ({:player/id 124, ; :player/name "Frank", ; :player/position :midfield, ; :team/id 432, ; :team/name "Durham Denizens", ; :team/division :eastern} ; {:player/id 123, ; :player/name "Russell", ; :player/position :point-guard, ; :team/id 432, ; :team/name "Durham Denizens", ; :team/division :eastern})
  continue reading

118 قسمت

همه قسمت ها

×
 
Loading …

به Player FM خوش آمدید!

Player FM در سراسر وب را برای یافتن پادکست های با کیفیت اسکن می کند تا همین الان لذت ببرید. این بهترین برنامه ی پادکست است که در اندروید، آیفون و وب کار می کند. ثبت نام کنید تا اشتراک های شما در بین دستگاه های مختلف همگام سازی شود.

 

راهنمای مرجع سریع

در حین کاوش به این نمایش گوش دهید
پخش