From jan@swi.psy.uva.nl Thu May 10 16:08:51 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 f4AE8p311805;
	Thu, 10 May 2001 16:08:51 +0200 (MET DST)
Received: (from jan@localhost)
	by gollem.swi.psy.uva.nl (8.11.2/8.11.2/SuSE Linux 8.11.1-0.5) id f4AE8jj01433;
	Thu, 10 May 2001 16:08:45 +0200
Date: Thu, 10 May 2001 16:08:45 +0200
Message-Id: <200105101408.f4AE8jj01433@gollem.swi.psy.uva.nl>
From: Jan Wielemaker <jan@swi.psy.uva.nl>
Subject: Re: [SWIPL] Can someone help me?
To: Aurelio Magalhaes Dias <amd@atlas.ucpel.tche.br>, prolog@swi.psy.uva.nl
In-Reply-To: Aurelio Magalhaes Dias's message of Thu, 10 May 2001 10:55:24 -0300 (EST)
Phone: +31 - 20 - 525 6121

> Hi, if I have a consult like this ...
> 
> ?- soma([2,4],3).
> 
> and this code ...
> 
> soma(X,Y):-
> 	X = [X1,Y1],
> 	Y = Y2,
> 	S1 is X1+Y2,
> 	S2 is Y1+Y2,
> 	print([S1,S2]).
> 
> ... why it doens't work giving me the error:
> 
> ?- soma([2,4],3).
> [WARNING: '.'/2: Type error: `[]' expected, found `[4]']
>  ^ Exception: (  9) _L123 is[2, 4]+3 ? creep
>    Exception: (  8) soma([2, 4], 3) ? creep
> [WARNING: Unhandled exception]
> 
> Execution Aborted
> 
> Can someone give me a hand ?

It's a bit odd code, but I think you didn't copy it right as the code
above is fine and works fine (SWI-Prolog 4.0.5 on Linux).

The exception itself looks a bit criptic, but results from
the fact that "a" evaluates to the code if the letter `a' (normally 97).
This happens because "a" is read as [97], which is .(97, []) and ./2
is defined as an arithmetic function that expects the 2nd argument to
be [] and the 1st argument to be an integer.

Look at the archives or a good Prolog book to see why you shouldn't
be using lists here in the first place.

	---- Jan

