Created
June 3, 2011 11:05
-
-
Save samof76/1006184 to your computer and use it in GitHub Desktop.
Erlang Install - Sample
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-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