Friday, April 5, 2013

Functional Programming for the Object-Oriented Programmer: Exercise 1 & 2

The first section of this book introduces you to Clojure - mainly how the read evaluate and print processing works.

You're introduced to:

  • Defining functions
  • Built in functions such as nth
  • Naming things such as functions and values
  • Lists
The exercises are to define a function that returns the second element in a list and at least a couple of implementations of a function that returns the third element in the list. 

Here are my implementations of second:


And here are my implementations of third:

I've used the inbuilt functions nth, first, rest and done an implementation of third that uses one of my implementations of second.

No comments: