Super simple example
% Prolog
next_light(green, yellow).
next_light(yellow, red).
next_light(red, green).
% Erlang
next_light(green) -> yellow;
next_light(yellow) -> red;
next_light(red) -> green.
Notable differences:
- `;` in Erlang indicates multi clause function
- In Prolog next_light is database, in Erlang it's just a function
Question: What's the light before green?
% Erlang
% Returns actual value
prev_light_search() ->
[State || State <- [green, yellow, red], next_light(State) == green].
% Prolog (?- means that it's in query mode)
?- next_light(Light, green).
So syntax IS similar though the thing is that Prolog is more like binding and quering database and Erlang is executing function.
In a nutshell Erlang is more like: "when I have X, then I can calculate Y" and Prolog like "If I want Y, what's the X".