Deep dive into data


#1

Originally published at: https://purelyfunctional.tv/intro-to-clojure/deep-dive-into-data/
The third and final part of Intro to Clojure is all about data-driven programming. That’s where you define a data structure that looks like the thing it means. In our case, we’re making a data structure that looks like a recipe. Then there’s a function that can interpret that recipe and bake it. Part 3 is 24 minutes long.


#2

Hi Eric,
(@ericnormand)

If I’m not missing something, I notice at the 16 min mark of video 3 that while we are editing fetch-ingredient, the function isn’t actually being used anywhere. The function day-at-the-bakery is calling fetch-list which in the video seems to be doing work intended for the newly edited fetch-ingredient.

Did I miss an edit step for day-at-the-bakery? I went through all the videos twice so I hope not. I’m half way through video 3 and don’t want to jump ahead and cheat my learning. Am I missing something? Thanks!

My best,
Jay


#3

Just after this, Ex. 12 asks that we rewrite fetch-list to remove :pantry and :fridge etc.

The solution provided uses group-by but is rather long when compared to:

(defn fetch-list [shopping-list]
  (doseq [[ingredient amount] shopping-list]
    (fetch-ingredient ingredient amount)))

This may have been an oversight when authoring the exercises or I could be missing something. Interestingly, the (day-at-the-bakery) runs fine with this code. Thanks for any feedback!


#4

Hi @Jay_Martin,

Trying to remember what this code was about.

I think your code would run fine except it will make many trips to the pantry and fridge. The idea behind the other code was to minimize trips by grouping together the ingredients.

Thanks
Eric