Skip to content

Instantly share code, notes, and snippets.

@patrickgombert
Last active December 16, 2015 16:39
Show Gist options
  • Save patrickgombert/5464619 to your computer and use it in GitHub Desktop.
Save patrickgombert/5464619 to your computer and use it in GitHub Desktop.
anwer(foo, Args) -> % pattern match the arguments
answer_to_foo; % notice the semi-colon
answer(bar, Args) ->
case Delicious of
veggies ->
false; % Again, notice the semi colon
bacon -> % case is another form of pattern matching
true % The last statement in the case has no punctuation
end;
answer(baz, Args) ->
answer_to_baz. % The last match has the period
%%%%%%%%%%%%%%%%%
answer(ping, []) -> Return the atom pong
answer(pascal, [NthRow]) -> Return the nth row of pascal's
triangle as a list
answer(bowling, [FirstThrow, SecondThrow .. NthThrow]) ->
Return the score for a given
bowling game
answer(roman_numerals, [Number]) -> Return the roman numeral
for the given number
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment