• Skip to main content
  • Skip to footer

PurelyFunctional.tv

  • Learn Clojure
  • About
  • 🛒 Cart
  • Log in

Want to learn Clojure? It doesn't have to be hard!

Maybe you've heard of Clojure. Maybe you even tried to learn it. If you did, you may have had some of these problems:

  • Trouble getting Clojure installed and working
  • What text editor should you use?
  • The syntax is foreign and strange
  • There's so much to learn
  • What practical thing can you even build?

These problems are hard to figure out on your own, and many tutorials skip over these. Wouldn't it be nice if you had:

  • A clear guide to installing Clojure on your system
  • A great text editor without installing anything new
  • A gentle introduction to the syntax without dwelling on it
  • Someone teach you just what you need to learn right when you need it
  • A fun, engaging activity to get you programming right away

Let me tell you about ...

Introduction to Clojure (v2)

Introduction to Clojure is a gentle tutorial for Clojure. It will get you started quickly and painlessly. You'll teach a robot how to bake cookies, cake, and brownies--and learn Clojure along the way!

This is the updated and expanded course that has been used by hundreds of people to learn Clojure over the years.

Introduction to Clojure v2

Updated February 24, 2021

Want this course?

Online License

$48
Get this course
--
Watch Online
Lifetime Access
For an individual
Buy for $48

Love it or leave it guarantee

If you don't learn as much from this course as you thought, just ask for a refund within 30 days and I'll give you your money back.

Video time: 06h08m
0 / 60
0 / 60

Lessons

12 min Free

1. Introduction

How to use the course. What is Clojure and why do people use it? How to get set up for the course.

2 min Free

2. Introducing X5 and JC

We introduce X5, who wants to be a baker. He's going to baking school. JC is his baking instructor. We'll be helping X5 learn, by using Clojure.

14 min Free

3. Working with the REPL

We start off our journey by baking some cookies and a cake. We learn how to use each ingredient and how to follow recipes.

7 min

4. Defining functions

We learn how to call functions and define new ones.

2 min

5. Defining a bake-cake function

We define a function to bake a cake.

10 min

6. Conditionals

We learn how to choose different code to evaluate based on a condition.

2 min

7. Defining scooped?

We write a function that can tell us whether we need to scoop an ingredient.

3 min

8. Defining squeezed?

We define a function to determine whether an ingredient is squeezed.

1 min

9. Defining simple?

We define a function to decide whether an ingredient is simple.

11 min

10. Defining ingredient types

We develop functions that add certain ingredient types.

10 min

11. Looping a number of times

Let's learn how to iterate a certain number of times using dotimes.

2 min

12. Using the plural functions

We'll use our new functions to refactor our baking function.

15 min

13. Variadic functions

We learn to write functions that can take a variable number of arguments and use a common pattern for handling default argument values.

2 min

14. Baking with variadic functions

Now we can rework our bake-cake function to use the variadic versions of our add functions.

2 min

15. Bake cookies function

We can now define a function called bake-cookies to implement the cookies recipe we thought before.

2 min

16. Day 1 Conclusion

Let's wrap up our first day at the bakery and take a look at what we've accomplished.

11 min

17. Running Leiningen projects

In this first lesson, we'll take a tour of a Clojure project and learn how to run it. We'll also take a look at the editor we'll be using to edit the code for the rest of the course.

11 min

18. Error function

We define a function to indicate an error.

4 min

19. Refactoring errors

Let's now use the error function we just wrote and replace all of the error expressions we've already got with calls to it.

14 min

20. Bakery locations

We learn about the different locations that X5 can go to in the bakery. We learn about sets and what they can hold.

2 min

21. Scooped?, squeezed?, and simple? refactor

We refactor scooped?, squeezed?, and simple? to use the same pattern we just wrote.

9 min

22. Fetching ingredients

We need to go fetch ingredients from different locations. Let's write a function that will go to the right location and fetch an ingredient and bring it back to the prep area.

3 min

23. Fetch ingredients generic

We can now write a function that will just take the ingredient as an argument and decide where to go to fetch it.

7 min

24. Maps

We learn about another data structure called maps (hash maps).

10 min

25. Fetching a shopping list

We learn a new conditional and how we can begin fetching an entire shopping list with as few trips as possible.

10 min

26. Refactoring fetch-list

We start to refactor our big fetch-list function into smaller parts.

9 min

27. Refactoring locations

We have some duplication. Let's learn a new loop to go through all of the locations and fetch what we need from each.

20 min

28. A day at the bakery

Now that we have an efficient way of fetching ingredients, let's handle the orders for the day.

3 min

29. Analyzing a day at the bakery

Let's take a look at the day-at-the-bakery function and see how we can improve it.

10 min

30. Functional programming

Let's talk about Functional Programming. Then we can talk about combining ingredient lists.

6 min

31. Into

We also want to be able to multiply an ingredient list. For instance, if we need to make 3 cakes, we can multiply the ingredients for a cake by 3. That's not quite as easy as adding, but it's not hard. We just need a few more things.

7 min

32. multiply-ingredients

Now we can learn how to calculate one list from another and how to use it to multiply ingredients.

5 min

33. order to ingredients

We create a function that will take an order and return the ingredients needed to complete it.

7 min

34. orders to ingredients

Now we can write a function that takes a list of orders and gives you the whole list of ingredients you'll need to complete all of them.

3 min

35. Making one shopping trip

Let's now do one big shopping trip after we fetch the orders.

12 min

36. Making one delivery

The delivery bot is annoyed that we give him one receipt per baked good. Let's fix that by grouping them by order.

3 min

37. Day 2 conclusion

We review what we've learned and how our baking is doing.

2 min

38. Day 3

Today is X5's third day at the bakery. The first day, we learned how to use ingredients. In the second day, we learned how to calculate, basically plan ahead, before we started working, to make things more efficient.

Let's start with cleaning up some unused code.

2 min

39. Add cocoa

Let's add a new ingredient, namely cocoa.

6 min

40. Baking brownies

Let's add a recipe for a new baked good, brownies.

6 min

41. Analyzing recipes

We make note of some duplication and make a plan for removing it.

2 min

42. Starting the database

Let's get started on our database where we store bakery knowledge.

1 min

43. Perform

We need to write a function that can take actions. We'll start with cooling the pan.

1 min

44. Mix step

We add :mix to the perform function.

1 min

45. Pouring and baking

Let's add pour and bake to our perform function.

7 min

46. Adding ingredients

Let's add an action for adding ingredients.

4 min

47. Bake recipe

We make a generic bake-recipe function that looks up the steps in the database and bakes it.

3 min

48. Generic bake function

We can now rewrite bake to use the new bake-recipe function.

5 min

49. Adding all recipes

Now that we can bake recipes, let's add the other recipes, cookies and brownies.

6 min

50. Cleaning up order to ingredients

We get rid of the ingredients listed in the definition of order->ingredients and instead look them up in the database.

3 min

51. Ingredients in the database

We need to add a section to the database about where to fetch ingredients and how to use them.

2 min

52. Refactoring scooped, squeezed, and simple

We redefine scooped?, squeezed?, and simple? to use the baking database.

9 min

53. Generic fetch ingredient

We can now do a generic fetch-ingredient function that looks up the location in the database. That lets us get rid of the specific fetch-from-pantry and fetch-from-fridge functions.

10 min

54. Refactoring fetch-list (again)

Currently, we've defined a map called locations that lists the locations of all of the ingredients. It's duplicating what's in the database.

We learn a new tool, called group-by, that will allow us to drive the fetching of an entire list of ingredients by that list alone.

4 min

55. Make storage-location more useful

I'm not completely happy with storage-location. It's not a very valuable function outside of this one usage. We should really use a custom function just for the item-amount usage.

9 min

56. Redefining add

We refactor add to dispatch from a map based on usage type.

4 min

57. Defining actions

We can make a map for dispatching actions.

4 min

58. Refactoring perform

Now that we have the actions map, we can refactor perform to use it.

5 min

59. Conclusions

We conclude the course with reflections on what we've learned.

10 min

60. Appendix: Creating a Leiningen project

If you're curious about how the Leiningen project we used was created, I walk through the steps of creating a new project and setting up the bakery dependency.

Extra Resources

Introduction to Clojure Reference

Guide to baking for the intrepid robot

Footer CTA

Level up your Clojure skills

The PurelyFunctional.tv Newsletter is a weekly email that helps you improve your Clojure skills through challenges, tips, and news.

Enter your email address to receive emails about Clojure and Functional Programming. These include the weekly newsletter and occasional offers. You can unsubscribe any time.

Copyright © 2021 LispCast and Eric Normand