Updated 4_FUNctions.txt

suze88 authored
revision dbba9127ef2dd53f6d7e8835a2411956704200fa
4_FUNctions
# FUNctions

Every programming language has functions. You make 'em, you call 'em, you yell at them, and more. These properties are reminiscent of children in our physical world; and like children they are little bags of potential that can change your world.

Functions make things *easy* in programming. This is a rare and wonderful thing when it comes to a field that largely results in one scratching their head and pondering when trying to solve a problem. Think of them as mallaeble legos you can form into the strangest of things for whatever unique purpose you need. But, like having children, sometimes it is not the best call to declare a function out of nowhere. We won't get too far into the specific use-cases here. This is to be a guide on syntax, not best practices (that comes when we're pro as shit later).

### Defining a FUNction

Functions are very easy to define and work with in Clojure. Since it is a functional programming language, its a damn good thing they did this or we would be having a bad time. However, with great power comes great responsibility. And one of Clojure's many powers is there are a LOT of different means to go about defining functions. We got defn's, we got let's, we got regular ole def's too. We'll begin our evaluation with a simple def, much like we referenced in the earlier chapter "A Loose Introduction".

(def remove_pants [statement] (str statement "and then I took off my pants"))

Now, that line should make you cringe if you're not a masochist. It looks horrible. So since Clojure doesn't care about whitespace and linebreaks let's clean that bad boy up.

(def remove_pants
[statement]
(str statement "and then I took off my pants))

Now that looks nice and friendly. We can now stop and remove our pants whenever we damned well please! It's just like the first time you got your own crashpad, and it is glorious.