Subject: [SWIPL] arithmetic_function

From: Satoshi Ota (OOta) <[email-masked]>
Date: Sat, 14 Jul 2001 20:08:15 -0700

Hi

Because of a specific purpose, I need to write an arithmetic function
like:

:- arithmetic_function(sum/3).	

sum(X0, X, K, S) :-
	sum(X0, X, K, 0, S).

sum(X, X, _, S, S) :- !.
sum(X0, X, K, S0, S) :-
	S1 is S0 + 1,
	X1 is X0 + 1,
	sum(X1, X, K, S1, S).

It is obvious that it works if we give something like:

14 ?- A is sum(0, 4, 0).

A = 4 ;

However, what I want to do is as follows:

?- A is sum(0, 4, k).

It does not work because:

ERROR: Arithmetic: `k/0' is not a function

Does anybody know why it did not work?

Thanks,

---
Satoshi