Home > Archive > Prolog > January 2006 > ERROR: Arithmetic: a/0 is not a function" number
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
ERROR: Arithmetic: a/0 is not a function" number
|
|
|
| Hello,
I have just written:
l(T1,T2):- number(T1),T2 is 2*T1.
l(T1,T2):- not(number(T1)),T2 is T1.
It have to double the numbers, and pass the rest. However when I run it:
l(a,X).
I got:
ERROR: Arithmetic: a/0 is not a function" number
Which is a very crazy thing. When i write:
number(a).
I just got:
Yes.
What's wrong?
Regards,
Talthen
| |
| Bart Demoen 2006-01-23, 7:03 pm |
| talthen.z-serwera.o2@nospam.pl wrote:
> Hello,
> I have just written:
> l(T1,T2):- number(T1),T2 is 2*T1.
> l(T1,T2):- not(number(T1)),T2 is T1.
> It have to double the numbers, and pass the rest. However when I run it:
> l(a,X).
> I got:
> ERROR: Arithmetic: a/0 is not a function" number
?- l(a,X).
triggers the goal "T2 is a" (because not(number(a)) succeeds) and that
causes the error message: arithmetic is on numbers, predefined functions
and user-defined functions (assuming you are using SWI) and a/0 seems to
be none of those.
Perhaps you meant T2 = T1 in the second clause of ;/2
>
> Which is a very crazy thing. When i write:
> number(a).
> I just got:
> Yes.
That is a crazy thing, because when you write number(a) as in a query,
it should say NO.
And if you write it as a fact, it should say something including
No permission to modify static_procedure `number/1'
Cheers
Bart Demoen
| |
|
| User "Bart Demoen" <bmd@cs.kuleuven.be>
> Perhaps you meant T2 = T1 in the second clause of ;/2
l(T1,T2):- number(T1),T2 is 2*T1.
l(T1,T2):- not(number(T1)),T2 = T1.
The above works, but it is a bit weird to me ;/
> That is a crazy thing, because when you write number(a) as in a query, it
> should say NO.
It does indeed. My mistake :]
Thanks for help.
Regards,
Talthen
| |
| Nick Wedd 2006-01-24, 7:56 am |
| In message <dr3dos$kjt$1@atlantis.news.tpi.pl>,
talthen.z-serwera.o2@nospam.pl writes
>l(T1,T2):- not(number(T1)),T2 = T1.
>
>The above works, but it is a bit weird to me ;/
It is a bit weird. If T2 and T1 are identical, why use two different
variables? It must be better to use one variable:
l(T,T):- not(number(T)).
Nick
--
Nick Wedd nick@maproom.co.uk
| |
| Bart Demoen 2006-01-24, 7:56 am |
| Nick Wedd wrote:
> In message <dr3dos$kjt$1@atlantis.news.tpi.pl>,
> talthen.z-serwera.o2@nospam.pl writes
>
>
>
> It is a bit weird. If T2 and T1 are identical, why use two different
> variables? It must be better to use one variable:
>
> l(T,T):- not(number(T)).
But you changed the semantics ! Try ?- l(X,1). in both cases and you will see.
Cheers
Bart Demoen
|
|
|
|
|