Have you ever thought to yourself, “What can I do with all my spare time” or maybe “There are all these people at work, that I really would like to get to know better”?  No, really, oh well I have.  The game plan I came up with was simple, find something that was related to work but happened after work and beer was provided.  The answer to all the worlds problems is Erlang, dun dun duda….  Ok maybe not, but the newly re-minted Erlang-NYC meetup group was the answer to my problems.  For those of you who have never heard of this “Meetup” idea, it is a group of people getting together to talk or act on a unified topic or activity.  This meetup’s unified topic is Erlang, DUH, and they get together about once a month or more.

One of the series the group is doing follows along with a beginners guide to Erlang called, Études for Erlang.  Every week we meet to go through one of the chapters from the guide and hopefully we all become more familiar with the language, while making friends with people of similar interests.  This week (06/10/2013) we had our first meeting to go through chapters 1 and 2.  Here are my solutions:

Chapter 1: Getting Comfortable with Erlang

link

Try leaving out parentheses in arithmetic expressions:

(1+1.
syntax error before: '.'

Try adding "adam" to 12:

"adam" + 12.

** exception error: an error occurred when evaluating an arithmetic expression
 in operator +/2
 called as "adam" + 12

Make up variable names that you are sure Erlang wouldn’t ever accept

VarNameWithAmp& = 1.
* 1: syntax error before: '&'

VarNameWithUnderScore_Test = 12.
12

atom_trying_to_be_var = 2.
** exception error: no match of right hand side value 2

Chapter 2: Functions and Modules

link

Write a module with a function that takes the length and width of a rectangle and returns (yields) its area. Name the module geom, and name the function area. The function has arity 2, because it needs two pieces of information to make the calculation. In Erlang-speak: write function area/2.

%% @author C J Ross <connor311@gmail.com>
%% @doc Functions for calculating areas of geometric shapes.
%% @copyright 2013 C J Ross
%% @version 0.1

-module(geom).
-export([area/2]).

%% @doc Calculates the area of a rectangle, given the
%% length and width. Returns the product
%% of its arguments.

-spec(area(number(),number()) -> number()).
area(Height, Width) ->
	Height * Width.

Test:

2> c(geom).
{ok,geom}
3> geom:area(3,4).
12
4> geom:area(12,7).
84
5>

Generated EDoc:

Edoc - Geom

Looking forward to next week!  Hope you can join myself and other Medidatations at the 06/18/2013 Erlang-NYC Meetup.

Chapter 3