average(X) -> sum(X) / len(X). sum([H|T]) -> H + sum(T); sum() -> 0. len([_|T]) -> 1 + len(T); len() -> 0.
I have been really loving Python lately but after reading this post. I thought it would be a good idea to check out Erlang. I have heard its concurrency and network support is out of this world and being in a knowledge based industry extra knowledge never hurts. This simple code snippet shows how much Erlang differs from the traditional procedural languages.Download the source.
average takes at list X who calls sum and len. Both of those are recursive functions that split the list into the first element H and the remainder T. Variables must start with a capital letter and the '_' denotes the result is not used. Notice in this example no temporary variables were used. Talk about putting the "f" in functional. I can't wait to get to the concurrent stuff.
Below is a snippet of my resume. Click here to view the full version in pdf, its proper format.