O'Reilly logo

Clojure for Finance by Timothy Washington

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Namespaces and creating our first function

We now have the basis to create a function. It will return a lazy infinite sequence of floating point numbers within an upper and lower bound. defn is a Clojure function that takes an anonymous function and binds a name to it in a given namespace. A Clojure namespace is an organizational tool used to map human readable names to things, such as functions, named data structures, and so on. Here, we're going to bind our function to the generate-prices name in our current namespace. You'll notice that our function is starting to span multiple lines. This will be a good time to author the code in your text editor of choice. I'll be using Emacs (you can read more about Emacs at https://en.wikipedia.org/wiki/Emacs ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required