Hello to everyone,
I am studying from a prolog tutorial, but I have stuck in a programm, and can't figure it out at all. It's the perm predicate, I think it's in the prolog or sth, it's definition is this(with the definition of takeout too that it uses):
takeout(X,[X|R],R)...
Hi, I don't understand how this programm works.
reverse_list([], []).
reverse_list([Head | Tail], ReversedList) :-
reverse_list(Tail, ReversedTail),
append(ReversedTail, [Head], ReversedList).
It is assumed to reverse a list, but I don't know what calls does it make and with what order. Can...
In the 2 elements list, B was []. Now, in the 4 elements list, B is [[6,7]] from the clause you made that I didn't understand. I also don't understand this:
"B is the result of couples([6, 7], B)."
I'm quite confused. :S
No, I understand this equivalence, what I don't understand is this:
"We know that couples([6, 7], B) computes B = [[6, 7]] because [6, 7] is a 2-element list.
Sorry, I am not English and I can't explain it further. I' m talking about the meaning here and in the meaning we use firstly the if clause. That's what I 'm saying. In the Swi- prolog, it is obvious that it happens secondly, not firstly I was wrong.
I didn't understand how B is [[6,7]].
Yes, but again you explained me about what Swi-prolog does, I am talking about the meaning here. How can we say if for sth, if it happens first in the Swi-prolog and the meaning? That's what I'm saying. And also, I would like you to tell me if you can, what is saved in the B list when we insert...
Thank you, but I asked the opposite. What's the translation, the meaning of the second rule if we use if. Since the meaning starts from the second clause with if, then how the first action (the separation of H and H1) happens first. Now you got it?
But I have a general question, which for example in this programm, is that since we separate the H and H1 in the head of the rule, how can the body be the first action? Do you get what I mean? That we say first the body, but the first action is on the head of the rule. I don't understand how...
I didn't understand what I had done wrong, but I understood the explanation of the correct programm. :) About the first rule, I translated that when we finish rule 2, what shall we have for rule 1? So, my translation was wrong if you get it. Thank you so much for everything! Be well!
Sorry, pair_list is another name for couples.. So, my programm is that:
couples([], _).
couples([H, H1|A], B) :- append([H], [H1], L), couples(A, [L|B]).
Sorry, I don't understand your explanation, what I thought my programm does is:
First, seperates H and H1 from the body. It uses append to...
Hi, I want to apologize to all and especially Mr. Kahleen for my continuous asking for help, but I have boggled.
Here's what I have to do next, I have a list A and a list B with the couples of the elements of list A, for example: list A=[4,5,6,7,8,9] and list B=[[4,5],[6,7],[8,9]].
I have made a...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.