Let's get functional


Originally published at: https://purelyfunctional.tv/intro-to-clojure/lets-get-functional/
The purpose of the second part is to begin working in a real project structure and get into functional programming. Part 2 is 38 minutes long.


Just in case anybody else has trouble getting lein run to run (near the 4 minute mark) without a compile error:

Exception in thread "main" java.lang.IllegalStateException: bowl-state already refers to: #'bakery.core/bowl-state in namespace: clojureintro.core, compiling:(clojureintro/core.clj:6:1)

What I erroneously did was copy in the whole Video1.clj file which caused some name conflicts. It was hard for me to follow on the video what code Eric copied in, so I wrongly guessed the whole file.

To fix it, I undid the copy. Then, I copied the code we wrote in Video 1, plus these 4 lines of Eric’s which I had referred to in my own code.

(def ingredients #{:egg :flour :milk :sugar :butter}) (def grabbables #{:egg :cup :butter}) (def scoopables #{:flour :milk :sugar}) (def squeezables #{:egg})

Now lein run works and I can bake cakes and cookies. Yum! Maybe I did something else wrong, but I don’t think so.

My best,