getting specific elements from a list in Prolog -
I am reading this tutorial on Prol List, and how to get a specific element from the list, Came in:
? - [_, X, _, y | _] = [[], Dead (z), [2, [b, c]], [], z] x = dead (z) y = [] z = _ 9 9 What do I not understand, where do they get value 9 9 593 for variable Z? I am worried about the clarification of the Templar, although technical details are correct, I worry about getting the vocabulary. Okay.
No one is being assigned here. The only integration is what we are calling here to do prologue, [_, X, _, y | _] with [[], dead (z), [2, [b, c]], [], z] . This is not a result Instead of imagining to move to the left side of Prol, and then when it can not be true, then these lists can be more secure in imagining . First of all, Prologue tries to unite together []. It is trivial, because _ means "I do not care"
After this, try to unite X with the phrase dead (z) Does. It is trivially successful, because X was unbound, and it establishes a compulsive, x = dead (z) because this variable does not start with the underscores, Prolog figures you binding this , So it reports to you. Next, attempts to integrate Prolog with [2, [B, C]] . Again, it is trivial success without a compulsive installation. After this, with Prolog [] attempts to unite Y, it is again troublesome to succeed, but this time the binding Y = [] establishment which he told you. Before the next step, you must get an informative change. In Prol, [x | T] is a list that starts with X and continues with T. Therefore, [X | _] adds X with the first element of the list and removes the tail, so in this case | _] Essentially says, this list can be more, but I do not know specifically what this is. (By the way, the empty list will match.) After that, Prologue has an anonymous tail with jade | _ . Again, it succeeds successfully, because Z is not bound. Prol created an unknown variable and built it on Z, so it establishes a bond. So, the same information is given as @ templar, but with a slightly different vocabulary, here for your entertainment.
Comments
Post a Comment