It's really quite different, and I don't think I can fully do it justice in a comment. I will give my favourite example though: it certainly helped me get the "aha" moment.
Let's say you have a collection of cities, and a collection of roads between them. And you want to answer the question: "is there a route from City A to City E?"
A solution in prolog would look something like this:
/* First, the roads */
road("A", "B").
road("B", "C").
road("C", "D").
road ("D","E").
/* Now the algoritm */
route(From, To) :-
road(From, To).
route(From, To) :-
road(From,Intermediate), route(Intermediate,To).
That's it. There's no need to loop/iterate/check conditions. Simply state the facts, ask the question, and the prolog interpreter will search for an answer:
Because it creates a left-recursive call that will eventually cause a stack overflow. If you want to try it out, there's Swish[0] - an online prolog editor and interpreter.
Let's say you have a collection of cities, and a collection of roads between them. And you want to answer the question: "is there a route from City A to City E?"
A solution in prolog would look something like this:
That's it. There's no need to loop/iterate/check conditions. Simply state the facts, ask the question, and the prolog interpreter will search for an answer: