Skip to content

Instantly share code, notes, and snippets.

@studzien
Created November 7, 2014 21:38
Show Gist options
  • Save studzien/15dc980f91feb9743164 to your computer and use it in GitHub Desktop.
Save studzien/15dc980f91feb9743164 to your computer and use it in GitHub Desktop.
\lstdefinestyle{erlang}{
belowcaptionskip=1\baselineskip,
breaklines=true,
frame=L,
xleftmargin=\parindent,
language=C,
showstringspaces=false,
showlines=true,
basicstyle=\footnotesize\ttfamily,
keywordstyle=\bfseries\color{green!40!black},
commentstyle=\itshape\color{purple!40!black},
morekeywords={when, define, module, export, include},
identifierstyle=\color{blue},
stringstyle=\color{orange},
captionpos=b,
numbers=left,
}
\begin{lstlisting}[style=erlang, caption=Plik fac.erl, label=lis:facERL]
-module(fac).
-export([fac/1]).
-define(ERROR, "Invalid argument").
-include("fac.hrl").
fac(#factorial{n=0, acc=Acc}) ->
Acc;
fac(#factorial{n=N, acc=Acc}) ->
fac(#factorial{n=N-1, acc=N*Acc});
fac(N) when is_integer(N) ->
fac(#factorial{n=N});
fac(N) when is_binary(N) ->
fac(binary_to_integer(N));
fac(_) ->
{error, ?ERROR}.
\end{lstlisting}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment