[erlang-questions] Functional Programming

Lone Wolf <>
Wed Aug 29 18:58:16 CEST 2007


Hi.
  Consider please this Erlang code:
   
  code: 
    
---------------------------------
  
  

fac(1) ->
  1;
fac(N) ->
  N * fac(N - 1).

  
---------------------------------
    
I don't understand whats happening when I call:
fac(5)
I'm not sure but it seems to me it is "Recursion", right?
5 * fac(4)
4 * fac(3)
3 * fac(2)
etc.. 
  Thanks.


    Deep into that darkness peering, long I stood there, wondering, fearing, Doubting, dreaming dreams no mortal ever dreamed before.
  E.A Poe
  
   



       
---------------------------------
Boardwalk for $500? In 2007? Ha! 
Play Monopoly Here and Now (it's updated for today's economy) at Yahoo! Games.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20070829/a6beb5c5/attachment.html>


More information about the erlang-questions mailing list