Erlang:
-module(test).
-export([fac/1]).
fac(N) -> fac(N,1).
fac(0,A) -> A;
fac(N,A) -> fac(N-1,N*A).
--------------------------------
Haskell:
module Fac
where
fac(n)=facit(n,1)
facit(0,m) = m
facit(n,m)=facit(n-1,n*m)
-module(test).
-export([fac/1]).
fac(N) -> fac(N,1).
fac(0,A) -> A;
fac(N,A) -> fac(N-1,N*A).
--------------------------------
Haskell:
module Fac
where
fac(n)=facit(n,1)
facit(0,m) = m
facit(n,m)=facit(n-1,n*m)
留言