Skip to content

Instantly share code, notes, and snippets.

@samof76
Created June 3, 2011 11:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save samof76/1006184 to your computer and use it in GitHub Desktop.
Save samof76/1006184 to your computer and use it in GitHub Desktop.
Erlang Install - Sample
-module(fact). % This is the file 'fact.erl', the module and the filename MUST match
-export([fac/1]). % This exports the function 'fac' of arity 1 (1 parameter, no type, no name)
fac(0) -> 1; % If 0, then return 1, otherwise (note the semicolon ; meaning 'else')
fac(N) when N > 0, is_integer(N) -> N * fac(N-1).
% Recursively determine, then return the result
% (note the period . meaning 'endif' or 'function end')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment