From dmiles@teknowledge.com  Tue Dec 19 19:40:03 2000
Received: from helium.teknowledge.com (promethium.teknowledge.com [128.136.192.50])
	by swi.psy.uva.nl (8.9.3/8.9.3) with ESMTP id TAA01998
	for <prolog@swi.psy.uva.nl>; Tue, 19 Dec 2000 19:40:02 +0100 (MET)
Received: by helium.teknowledge.com with Internet Mail Service (5.5.2650.21)
	id <WM9NX6PZ>; Tue, 19 Dec 2000 10:36:19 -0800
Message-ID: <EE25484266A64A47AE06CFC47C64232B1A1857@helium.teknowledge.com>
From: "Douglas R. Miles" <dmiles@teknowledge.com>
To: "'Andre Araujo'" <andre@f2s.com>,
        "'prolog@swi.psy.uva.nl'"
	 <prolog@swi.psy.uva.nl>
Subject: RE: [SWIPL] if then else
Date: Tue, 19 Dec 2000 10:36:02 -0800
MIME-Version: 1.0
X-Mailer: Internet Mail Service (5.5.2650.21)
Content-Type: text/plain;
	charset="iso-8859-1"

From section 3.7 of the SWI manual 


+Condition *-> +Action ; +Else
This construct implements the so-called `soft-cut'. The control is defined
as follows: If Condition succeeds at least once, the semantics is the same
as (Condition, Action). If Condition does not succeed, the semantics is that
of (Condition, Else). In other words, If Condition succeeds at least once,
simply behave as the conjunction of Condition and Action, otherwise execute
Else. 

+Condition -> +Action
If-then and If-Then-Else. The ->/2 construct commits to the choices made at
its left-hand side, destroying choice-points created inside the clause (by
;/2), or by goals called by this clause. Unlike !/0, the choicepoint of the
predicate as a whole (due to multiple clauses) is not destroyed. The
combination ;/2 and ->/2 is defines as: 

If -> Then; _Else :- If, !, Then.
If -> _Then; Else :- !, Else.
If -> Then :- If, !, Then.

Note that the operator precedence relation between ; and -> ensure If ->
Then ; Else is actually a term of the form ;(->(If, Then), Else). The first
two clauses belong to the definition of ;/2), while only the last defines
->/2. 


On that note I tend to personally use allot of (()) around things since i
never want anything left to chance of some preexisting operator precedence
states..

For example

      give_the_test,
      	(
      		( grade_the_test ; accept_bribe )
				->
      			( write('the test passed'),nl)
	      	 	; 
      			( write('the test failed'),nl)
      	)


      
-----Original Message-----
From: Andre Araujo [mailto:andre@f2s.com]
Sent: Tuesday, December 19, 2000 6:29 AM
To: prolog@swi.psy.uva.nl
Subject: [SWIPL] if then else


Hi!

How do you create an in then else sructure?

Thanks!


----------------
* 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/


