users-prolog
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Question about compiling of files lgt, pl and c++


From: Paulo Moura
Subject: Re: Question about compiling of files lgt, pl and c++
Date: Mon, 17 Feb 2003 17:54:35 +0000


On Segunda, Fev 17, 2003, at 15:04 Europe/Lisbon, CARLOS EGEA wrote:

I have a problem when I want to link two files, a lgt
file and a pl file. For instance.

list.lgt

:-object(list).

   :-public(member/2).
   :-public(ocu/3).

    member(Element,[Element|_]).
    member(Element,[_|List]):-
       member(Element,List).
    ocu(X,Y,Z):-ocurrencia(X,Y,Z).
:-end_object.


pru.pl

ocurrencia(X,Y,Z):-Z is X+Y.

Write instead:

:-object(list).

   :-public(member/2).
   :-public(ocu/3).

    member(Element,[Element|_]).
    member(Element,[_|List]):-
       member(Element,List).
    ocu(X,Y,Z):-{ocurrencia(X,Y,Z)}.
:-end_object.

See the Logtalk documentation for a description of the {}/1 control construct.

But If I have the next, it goes well.

list.lgt

:-object(list).

   :-public(member/2).
   :-public(ocu/3).

    member(Element,[Element|_]).
    member(Element,[_|List]):-
       member(Element,List).
    ocu(X,Y,Z):-append(X,Y,Z).
:-end_object.

append is un built-in predicate, but It is defines in
other file and it goes well.

This second version of the list object works because append/3 is a built-in predicate (and detected as such by Logtalk).

Hope this helps,

Paulo


-----------------------------------------------------------
Paulo Jorge Lopes de Moura
Dep. of Informatics                   Office 4.3  Ext. 3257
University of Beira Interior          Phone: +351 275319700
6201-001 Covilhã                      Fax:   +351 275319891
Portugal

<mailto:address@hidden>
<http://www.logtalk.org/pmoura.html>
-----------------------------------------------------------





reply via email to

[Prev in Thread] Current Thread [Next in Thread]