Re:Why Learning Prolog Can Make You a Better Programmer
by danieldk on Friday April 08, 2011 @03:45PM
(#2425326)
There is a subset called "pure Prolog", which is restricted to Horn clauses. But regular Prolog (with extralogical features) is not functional, and definitely not pure. For instance, the proof_me predicate in the following program will be true, only once:
:- dynamic bla/0.
proof_me :-
\+ bla,
assert(bla).
Re:Why Learning Prolog Can Make You a Better Programmer
by _tef on Friday April 08, 2011 @03:15PM
(#2425220)
prolog is actually impure logic language, and given the general lack of HOF i'd be reticent in labelling it functional.
it's a declarative language though, and the model you have 'here is a query, what solutions exist' is reasonably accurate
Re:Why Learning Prolog Can Make You a Better Programmer
by tsewlliw on Friday April 08, 2011 @02:43PM
(#2425103)
not that depth first search isn't a pretty good analogy for what happens, but I believe it's SLDNF resolution, and I'm not 100% sure the exact algorithm is mandated by the language, though it might be for cuts.
It's been a while (some decades) since I wrote my last prolog program but this seems to be rather wrong to me. First of all, there is also the paradigm of logic programming and prolog is it's best known child. I don't think you can equate logic programming to functional programming. Secondly, there are no method calls as such. IIRC a prolog interpreter basically does a depth-first search on a graph made up of assertions. The very point of prolog is though that you don't tell the interpreter "call this method with these arguments and then do that" but rather you tell it "show me valid solutions that fit this template assertion, do however you think is best". At least that's what simple interpreters did. I don't know what more sophisticated compilers like gnu prolog made out of it. Please somebody correct me if I'm wrong. It's possible that my memory fails me.