News for hackers. Stuff that matters.
Re:The Mercury functional programming language by vram22 on Sunday March 28, 2021 @01:21PM (#26612168)
Thanks for the detailed reply.

>Sorry I can't think of a very good example right now

No problem.

I should say that I didn't understand your reply fully, due to not having the full necessary background. But I think I got the rough gist of the first half of the reply, and a part of the second half.

I had learned only a little Prolog, many years ago, just out of interest, only from books, and did not have access to any machine to try it on at the time. But I do remember bits of it, fuzzily (pun intended). So let me take a guess at what the second program means:

>even(0).

That is a fact stating: 0 is even.

>even(X):- r(X,Y), odd(Y).

That is a rule, stating:

X is even if there is a relation r between X and Y, and (comma means and in Prolog, IIRC) if Y is odd.

>odd(X):- r(X,Y), even(Y).

X is odd if there is a relation r between X and Y, and Y is even.

I don't understand the rest of the second half of your reply, at present, although I did think about it a bit. Maybe I need to study it more, or maybe I lack some prequisite knowledge.

>I don't know of any principled way to order clauses in a program to guarantee termination. That would be interesting to have.

Yes, I too think it would. That was the idea and question I originally asked about. I did intuitively think it was a difficult problem, but who knows, it may get solved in the future. I think that would make Prolog quite a bit more powerful.

Anyway, good to know that my idea was not totally off base, at least. Cheers :)

Re:The Mercury functional programming language by YeGoblynQueenne on Sunday March 28, 2021 @04:05PM (#26613912)
Apologies, I assumed a background in logic programming -I should have explained things better. Yes, your interpretation of the second prorgam is correct and yes your idea is not off base at all :)
Re:The Mercury functional programming language by vram22 on Sunday March 28, 2021 @06:22PM (#26615273)
No problem, and thank you again :)