Bayesian Erlang: Help with translation from Prolog

Nick Linker <>
Fri Jan 13 04:41:03 CET 2006


Joel Reymont wrote:

> This was an easy one. I'm wondering if backtracking can be  
> implemented by catching pattern-matching exceptions, though. What do  
> you think?
>
> -module(p).
>
> -compile([export_all]).
>
> p({patient, cancer}) -> 0.1;
> p({patient, smoker}) -> 0.5.
>
> cp({patient, smoker}, {patient, cancer}) -> 0.8;
> cp(_, _) -> none.
>
> getp({A, B})
>   when is_tuple(A),
>        is_tuple(B) ->
>     case cp(A, B) of
>     none ->
>         Pba = cp(B, A),
>         Pa = getp(A),
>         Pb = getp(B),
>         Pba * Pa / Pb;
>     X ->
>         X
>     end;
>
> getp(A) -> p(A).
>

Sorry for the following dumb questions: why do you need Prolog? has the 
Prolog language any significant advantages comparing to other languages?

With best regards,
Linker Nick.



More information about the erlang-questions mailing list