In this case, that is All the code.
These are some toy exercises in the book "Learn Prolog Now!",
and the complete code for that exercise is:

vertical(line(point(X,Y),point(X,Z))).
horizontal(line(point(X,Y),point(Z,Y))).


vertical(line(point(1,1),point(1,3))).

vertical(line(point(1,1),point(3,2))).

horizontal(line(point(1,1),point(2,Y))).

horizontal(line(point(2,3),P)).

The url is:
http://lpn.swi-prolog.org/lpnpage.php?pagetype=html&pageid=lpn-htmlse5

So yeah, I'm a noob on both Prolog And Pilog XD

On Tue, Jul 3, 2018 at 12:36 AM Johann-Tobias Schäg <[email protected]>
wrote:

> It would be interesting to see the complete code. with All definitions.
>
> *Von:* [email protected]
> *Gesendet:* 3. Juli 2018 7:28 vorm.
> *An:* [email protected]
> *Antworten:* [email protected]
> *Betreff:* Re: Pilog unification of a nested predicate
>
> OK, I just got it XD
>
> I had too many parentheses in the query.
>
> The correct form is:
> (? (vertical line (point 1 2) (point 1 3)))
>
> But that leaves me with the question,
> Why is the syntax "(vertical line (..." instead of "(vertical (line ..." ?
>
> My best guess is that, internally, the symbol 'vertical gets consed into
> the rest of the predicate,
> as defined in its property list.
>
> that is, when you run:
> : (show 'vertical)
> vertical NIL
>    T (((line (point @X @Y) (point @X @Z))))
> -> vertical
>
> the name of the sym (vertical) gets consed into the (line (point @X @Y)
> (point @X @Z)) part,
> and since that's what is used to unify the query,
> the query must have that same "(vertical line ..." structure.
>
> But that's just a guess. If there is some deeper meaning I would be happy
> to know :D
>
> On Mon, Jul 2, 2018 at 11:23 PM Bruno Franco <[email protected]>
> wrote:
>
>> The prolog saga continues!
>> This time, I'm having trouble with unification.
>>
>> I have this predicate:
>> vertical(line(point(X, Y), point(X, Z))).
>>
>> That gets unified with this query:
>> vertical(line(point(1, 2), point(1, 3))).
>>
>> In prolog, this returns true.
>>
>> But when I run what I (think) is the equivalent pilog code:
>>
>> (be vertical (line (point @X @Y) (point @X @Z)))
>> (? (vertical (line (point 1 2) (point 1 3))))
>>
>> The query returns NIL
>>
>> Is my syntax wrong? Or should I have specified some other intermediate
>> predicate?
>>
>> Thank you
>>
>

Reply via email to