Skip to content

Instantly share code, notes, and snippets.

@hgsigner
Created October 31, 2013 19:47
Show Gist options
  • Save hgsigner/7255694 to your computer and use it in GitHub Desktop.
Save hgsigner/7255694 to your computer and use it in GitHub Desktop.
-module(useless).
-export([add/2, hello/0, greet_and_add_two/1, len/1, tail_fac/1, tail_fac/2]).
add(A,B) ->
A + B.
%% Shows greetings.
%% io:format/1 is the standard function used to output text.
hello() ->
io:format("Hello, world!~n").
greet_and_add_two(X) ->
hello(),
add(X,2).
len([]) -> 0;
len([_|T]) -> 1 + len(T).
tail_fac(N) -> tail_fac(N,1).
tail_fac(0, Acc) -> Acc;
tail_fac(N,Acc) when N > 0 -> tail_fac(N-1, N*Acc).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment