From emerson@ppgia.pucpr.br Mon May 14 19:35:41 2001 Received: from hermes.ppgia.pucpr.br (ppgia.pucpr.br [200.192.116.20]) by swi.psy.uva.nl (8.11.2/8.11.2) with ESMTP id f4EHZd309974 for ; Mon, 14 May 2001 19:35:40 +0200 (MET DST) Received: from ppgia.pucpr.br (loki.ppgia.pucpr.br [10.32.2.224]) by hermes.ppgia.pucpr.br (Postfix) with ESMTP id 93D3682B65 for ; Mon, 14 May 2001 14:35:20 -0300 (BRT) Sender: emerson@ppgia.pucpr.br Message-ID: <3B00176E.781E17D9@ppgia.pucpr.br> Date: Mon, 14 May 2001 14:35:43 -0300 From: Emerson =?iso-8859-1?Q?Lu=EDs?= dos Santos Organization: PPGIA - PUCPR X-Mailer: Mozilla 4.73 [pt_BR] (X11; U; Linux 2.2.16-13cl i686) X-Accept-Language: pt-BR, en MIME-Version: 1.0 To: prolog@swi.psy.uva.nl Subject: Re: [SWIPL] References: <001b01c0dc6f$ba69f280$fc02efc3@unemployed> Content-Type: multipart/alternative; boundary="------------4E73D76DEF6C5CAF405D5D98" --------------4E73D76DEF6C5CAF405D5D98 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit u should take a look at the use of the type of operator (second argument of op/3), by typing ?- help(op/3) or looking for another explanation in some book when u use xfy, u r telling Prolog the type of argument on the left side of the operator should be a term with a lower precedence; however the second one may be a term with a precedence lower or equal to the precedence of the functor as u r trying to do it with a term which has a precedence equal to the precedence of the functor (as they are the same operator, they have the same precedence), Prolog will add brackets in order to respect the definition of the operator in op/3, because a term enclosed in brackets has precedence 0 if u want to get that result without any brackets, u have to declare it as :- op(120, yfy, w). then, the following query (intended by u) ?- conc(a w b, c w d, X). X = a w b w c w d Yes will succed the way u want it to îÉËÏÌÁÊ æÅÄÏÒÏ× wrote: > Hi. > > :- op(120, xfy, w). > > conc(X, Y, X w Y). > > [debug] ?- conc( a w b, c w d, X). > Call: (6) conc(a w b, c w d, _G404) ? creep > Exit: (6) conc(a w b, c w d, (a w b)w c w d) ? creep > > X = (a w b)w c w d > > Yes > [debug] ?- > > Why not X = a w b w c w d ? > How can I eliminate this? > > Thanx one more time. > /Nick/ > > ---------------- > * To UNSUBSCRIBE, please use the HTML form at > > http://www.swi.psy.uva.nl/projects/SWI-Prolog/index.html#mailinglist > > or send mail to prolog-request@swi.psy.uva.nl using the Subject: "unsubscribe" > (without the quotes) and *no* message body. > > ** An ARCHIVE of this list is maintained at > > http://www.swi.psy.uva.nl/projects/SWI-Prolog/mailinglist/archive/ -- £############################################################£ #¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬ Emerson Luís dos Santos ¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬# #************************************************************# #! Mestrando - Laboratório AGP/Siemens.......................# #! Grupo de Sistemas de Informação...........................# #! Programa de Pós-Graduação em Informática Aplicada - PPGIA # #! Pontifícia Universidade Católica do Paraná - PUCPR........# #! ¹ Curitiba - ² Paraná - ³ Brasil..........................# #************************************************************# #___________ Powered by Projeto i-Doc (Intelligent Document) # ¢############################################################¢ --------------4E73D76DEF6C5CAF405D5D98 Content-Type: text/html; charset=us-ascii Content-Transfer-Encoding: 7bit u should take a look at the use of the type of operator (second argument of op/3), by typing ?- help(op/3)
or looking for another explanation in some book
when u use xfy, u r telling Prolog the type of argument on the left side of the operator should be a term with a lower precedence; however the second one may be a term with a precedence lower or equal to the precedence of the functor
as u r trying to do it with a term which has a precedence equal to the precedence of the functor (as they are the same operator, they have the same precedence), Prolog will add  brackets in order to respect the definition of the operator in op/3, because a term enclosed in brackets has precedence 0
if u want to get that result without any brackets, u have to declare it as

:- op(120, yfy, w).

then, the following query (intended by u)

?-  conc(a w b, c w d, X).

X = a w b w c w d

Yes

will succed the way u want it to
 

îÉËÏÌÁÊ æÅÄÏÒÏ× wrote:

Hi.

:- op(120, xfy,  w).

conc(X, Y, X w Y).

[debug]  ?- conc( a w b, c w d, X).
   Call: (6) conc(a w b, c w d, _G404) ? creep
   Exit: (6) conc(a w b, c w d,  (a w b)w c w d) ? creep

X = (a w b)w c w d

Yes
[debug]  ?-

    Why not  X = a w b w c w d ?
    How can I eliminate this?

Thanx one more time.
/Nick/

----------------
* To UNSUBSCRIBE, please use the HTML form at

    http://www.swi.psy.uva.nl/projects/SWI-Prolog/index.html#mailinglist

or send mail to prolog-request@swi.psy.uva.nl using the Subject: "unsubscribe"
(without the quotes) and *no* message body.

** An ARCHIVE of this list is maintained at

    http://www.swi.psy.uva.nl/projects/SWI-Prolog/mailinglist/archive/

-- 


£############################################################£
#¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬ Emerson Luís dos Santos ¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬#
#************************************************************#
#! Mestrando - Laboratório AGP/Siemens.......................#
#! Grupo de Sistemas de Informação...........................#
#! Programa de Pós-Graduação em Informática Aplicada - PPGIA #
#! Pontifícia Universidade Católica do Paraná - PUCPR........#
#! ¹ Curitiba - ² Paraná - ³ Brasil..........................#
#************************************************************#
#___________ Powered by Projeto i-Doc (Intelligent Document) #
¢############################################################¢
  --------------4E73D76DEF6C5CAF405D5D98--