<table cellspacing='0' cellpadding='0' border='0' ><tr><td valign='top' style='font: inherit;'>Eshell V5.6.2 (abort with ^G)<br>1> fibo(12).<br>** exception error: undefined function shell_default:fibo/1<br>2> fibonacci:fibo(12).<br>** exception error: undefined function fibonacci:fibo/1<br>3> <br><br>this works in the shell so there is nothing wrong with the function. if i compile a buffer in emacs with erlangmode it starts the repl/shell but i cant seem to access the functions in the file.<br><br>-module(fibonacci).<br>-export([fib/1,fibo/1, fibo2/1, fibo3/1]).<br><br>fib_i(A, _B, 0) -> A;<br>fib_i(A, B, N) when N > 0 -> fib_i(B, A + B, N - 1).<br>fib(N) -> fib_i(0, 1, N).<br><br>fibo(0) -> 0 ;<br>fibo(1) -> 1 ;<br>fibo(N) when N > 0 -> fibo(N-1) + fibo(N-2) .<br><br><br><br>fibo2_tr( 0, Result, _Next) -> Result ; %% last recursion output<br><br>fibo2_tr( Iter, Result, Next) when Iter > 0 ->
fibo2_tr( Iter -1, Next, Result + Next) .<br><br>fibo2( N) -> fibo2_tr( N, 0, 1) .<br><br>fibo3(N) -><br> {Fib, _} = fibo3(N, {1, 1}, {0, 1}),<br> Fib.<br><br>fibo3(0, _, Pair) -> Pair;<br>fibo3(N, {Fib1, Fib2}, Pair) when N rem 2 == 0 -><br> SquareFib1 = Fib1*Fib1,<br> fibo3(N div 2, {2*Fib1*Fib2 - SquareFib1, SquareFib1 + Fib2*Fib2}, Pair);<br>fibo3(N, {FibA1, FibA2}=Pair, {FibB1, FibB2}) -><br> fibo3(N-1, Pair, {FibA1*FibB2 + FibB1*(FibA2 - FibA1), FibA1*FibB1 + FibA2*FibB2}).<br></td></tr></table><br>
<hr size=1><table><tr><td>Sök efter kärleken! <br>Hitta din tvillingsjäl på Yahoo! Dejting: <a href="http://ad.doubleclick.net/clk;185753627;24584539;x?http://se.meetic.yahoo.net/index.php?mtcmk=148783">http://se.meetic.yahoo.net</a></td></tr></table>