Help prolog "NEWBIE"
From: Riccardo (ricky_diabolos_at_hotmail.com)
Date: 02/06/04
- Previous message: Galileo: "Re: ¿Prolog en español?"
- Next in thread: Nick Wedd: "Re: Help prolog "NEWBIE""
- Reply: Nick Wedd: "Re: Help prolog "NEWBIE""
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 6 Feb 2004 12:20:26 -0800
Hi guys! I need a hand from anyone that knows something about prolog
, I will have an oral test where I had to explain this project.
-----------------------------------------------------------------------------
Define a predicate in PROLOG call averStud that
applied on a student ID number 'Matr' and on a
list of exams LE give as result the average AV of his votes.
Every exam shuold be represented by a term of list LE like the
following form ' exam(Matr,Exam,Vote).'
-------------------------------------------------------------------------
i have the solution , but i need help with the comment!
Thx in advice.
Solution:
averStud(S,L,AV) :-
totStud(S,L,N,T),
N > 0,
AV is T/N.
totStud(_,[],0,0) :- !.
totStud(S,[esame(S,_,V)|R],N,T) :- !,
totStud(S,R,NN,TT),
N is NN + 1, T is TT + V.
totStud(S,[_|R],N,T) :-
totStud(S,R,N,T).
- Previous message: Galileo: "Re: ¿Prolog en español?"
- Next in thread: Nick Wedd: "Re: Help prolog "NEWBIE""
- Reply: Nick Wedd: "Re: Help prolog "NEWBIE""
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|