Wrapping Up

In this chapter we took a look at how flexible a Clojure function can be. We’ve seen how you can define functions that take a variable number of arguments and at how you can hang a bit of documentation on your function. We also looked at multimethods, which enable you to define functions that execute different code depending on the arguments they are passed. We’ve seen how to write functions that take advantage of tail recursion and we’ve had a tour of pre and post conditions, which enable you to validate the data entering and leaving your functions.

Now that we’ve taken a good look at what a Clojure function is capable of, it’s time to address a bigger question: Why are functions so central to Clojure programming that we call Clojure ...

Get Getting Clojure now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.