Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

arithmetic-function with a list ??

Status
Not open for further replies.

HazemSayed

Programmer
Jan 1, 2011
1
EG
sum([],0).
sum([H|T],S) : - sum(T,X),S is X+H.
mean([],0).
mean(L,M) : - sum(L,S),length(L,L1),M is S/L1.
:-arithmetic_function(mean/1).
---------------------------------------
when i try mean([1,2,3,4],X).
it replies with
X= 2.5
Yes
///////////////////////////////////////////
Now I wanna Use ?- X is mean ([1,2,3,4].
but it repies with Type error: ERROR: '.'/2: Type error: `[]' expected, found `[2, 3, 4]' ("x" must hold one character)
----------
How Can use arithmetic-function with a list ??
plz any one help me :(
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top