From jan@swi.psy.uva.nl Wed Sep 26 16:46:50 2001
Received: from gollem.swi.psy.uva.nl (root@gollem [145.18.152.30])
	by swi.psy.uva.nl (8.11.2/8.11.2) with ESMTP id f8QEkov00834;
	Wed, 26 Sep 2001 16:46:50 +0200 (MET DST)
Received: from localhost (localhost [[UNIX: localhost]])
	by gollem.swi.psy.uva.nl (8.11.2/8.11.2/SuSE Linux 8.11.1-0.5) id f8QEknr19625;
	Wed, 26 Sep 2001 16:46:49 +0200
From: Jan Wielemaker <jan@swi.psy.uva.nl>
Organization: SWI, University of Amsterdam
To: scritch mephisto <scritch_mephisto@excite.com>, prolog@swi.psy.uva.nl
Subject: Re: [SWIPL] Help w/module loading
Date: Wed, 26 Sep 2001 16:42:22 +0200
X-Mailer: KMail [version 1.0.29.2]
Content-Type: text/plain
References: <17490245.997727882175.JavaMail.imail@seamore.excite.com>
In-Reply-To: <17490245.997727882175.JavaMail.imail@seamore.excite.com>
MIME-Version: 1.0
Message-Id: <01092616464901.19526@gollem>
Content-Transfer-Encoding: 8bit

On Mon, 13 Aug 2001, scritch mephisto wrote:
>Howdy,
>
>Brand new to Prolog, I need a little hand holding.  Basically, I
>need the modulus operator (mod).  Can someone explain the following
>interaction?
>
>First of all, here is my .plrc (note, autloading is on and verbose).
>:- set_prolog_flag(autoload, true).
>:- set_prolog_flag(verbose_autoload, true).
>
>And, here is some interactive Prolog:
>?- help(mod).
>%  library(helpidx) compiled into help_index 0.13 sec, 125,484 bytes
>% /usr/lib/swi-prolog/library/help compiled into online_help
>0.14 sec, 138,868 bytes
>% /usr/lib/swi-prolog/library/backcomp compiled into backward_compatibility
>0.00 sec, 3,812 bytes
>% /usr/lib/swi-prolog/library/quintus compiled into quintus
>0.02 sec, 11,772 bytes
>+IntExpr1 mod +IntExpr2
>[snipped]
>Yes
>
>
>?- 5 mod 2.
>ERROR: Undefined procedure: mod/2

mod/2 is a *function*, not a *predicate*, so it only
means anything as argument to is/2, =:=/2, </2, etc.

Built-in functions are not subject to the module system.

>?- 2 = 17 mod 5.

Simply tries to *unify* 2 with mod(17,5), which clearly fails.

>?- 2 is 17 mod 5.
>
>Yes

is/2 *evaluates* 17 mod 5, yielding 2, which unifies with 2,
so the answer is `yes'.

>But then why does this similar example not work:
>min(10, X).

What is this supposed to do?  min is a function taking the
minimum of its arguments, making X is min(2,3) yield X=2.

	--- Jan

