[erlang-questions] or?

Rodrigo Ahumada <>
Wed Jun 18 19:50:10 CEST 2008


El mié, 18-06-2008 a las 16:44 +0000, Circular Function escribió:
> if i instead of :
> 
> fib(N) ->
>         if
>                 N > 1 ->
>                         fib(N-1) + fib(N-2);
>                 N == 1 ->
>                         1;
>                 N == 0 ->
>                         0
>         end.
> 
> want to do:
> 
> fib(N) ->
>         if
>                 N > 1 ->
>                         fib(N-1) + fib(N-2);
>                 N == 1 or N == 0 ->
>                         N
>         end.
> 
> it doenst work, how do i use or?
> http://www.erlang.org/doc/reference_manual/part_frame.html
> doesnt provide an actual example of how to use it.
> 
> 
in the "if" you have to put Guard sequences, not boolean expressions
something like this:

N == 1; N == 0 -> N

the ; is the prolog OR. 


it's a case of atavism i think.

> 
> ______________________________________________________________________
> Låna pengar utan säkerhet.
> Sök och jämför hos Yahoo! Shopping.
> _______________________________________________
> erlang-questions mailing list
> 
> http://www.erlang.org/mailman/listinfo/erlang-questions

__________________________________________________
Correo Yahoo!
Espacio para todos tus mensajes, antivirus y antispam ¡gratis! 
¡Abrí tu cuenta ya! - http://correo.yahoo.com.ar



More information about the erlang-questions mailing list