It can be done, but it requires a subtle technique, the use of the y
combinator. Here's a link to a post from Bill Clementson which may
shed some light: <br><a href="http://bc.tech.coop/blog/070611.html" target="_blank">http://bc.tech.coop/blog/070611.html</a><br><br><div class="gmail_quote">2008/6/16 Circular Function <<a href="mailto:circularfunc@yahoo.se">circularfunc@yahoo.se</a>>:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><table border="0" cellpadding="0" cellspacing="0"><tbody><tr><td style="font-family: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-size: inherit; line-height: inherit; font-size-adjust: inherit; font-stretch: inherit;" valign="top">
6> Fac = fun(X) -> N * Fac(N-1).<br>* 1: syntax error before: '.'<br>6> Fac = fun(X) -> N * Fac(N - 1).<br>* 1: syntax error before: '.'<br>6> Fac = fun(X) -> N * fac(N - 1).<br>* 1: syntax error before: '.'<br>
6> fac = fun(X) -> N * fac(N - 1).<br>* 1: syntax error before: '.'<br><br>is it not possible to write recursive functions in the shell?<br>i have to do that ina module?<br>can i write functiosn any other way than making an anonymous one and assigning it to a variable?<br>
6> Sq = fun(X) -> X*X end.<br>#Fun<erl_eval..6.13229925><br>7> Sq(12).<br>144<br>8> <br></td></tr></tbody></table><div class="WgoR0d"><br>
<hr size="1">
Låna pengar utan säkerhet.<br>
<a href="http://shopping.yahoo.se/c-100390123-lan-utan-sakerhet.html?partnerId=96915014" target="_blank">Sök och jämför hos Yahoo! Shopping.</a></div><br>_______________________________________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br>
<a href="http://www.erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://www.erlang.org/mailman/listinfo/erlang-questions</a><br></blockquote></div><br>