I'm a beginner in Prolog and I have questions about the list manipulation and the sum of your items.
I have a historico(RA,[i1,i2,i3,...,in])
predicate where ra
is the Academic Record of a student and each i
is an item, with the form item(CM,SM,AN,NT,FQ)
, CM
being the code of the course, SM
is the semester, AN
is the year, NT
the grade, and FQ
the frequency.
In addition, the predicate curriculo(Codigocurso,[i1,i2,...,in])
where each i
is the code of a subject, shows the subjects of each course.
The predicate materia(Codigomateria,Nomemateria,Creditosmateria)
shows us how many credits each substance has in its third parameter.
Suppose I have the following facts:
historico(08080808,[item(1,1,2008,3.0,0.77),item(1,2,2008,6.5,0.90),item(5,1,2009,8.0,0.80)]).
materia(1,algoritmos_e_programacao_para_computadores_1,4).
materia(2,paradigmas_de_programacao,4).
materia(3,programacao_orientada_a_objetos,4).
curriculo(1,[1,2,3]).
I want to do a function that verifies the percentage of credits already fulfilled by a certain student.
For this, I will have the function porcentagemcreditos(RA,Codigocurso,Porcentagemjacumprida)
.
I need to first add the credits of all the subjects of the course of the student (considering the subjects present in the curriculum), but I do not know how to add the items of a list so that I have the total credits of a course. >
In addition, the porcentagemcreditos
function should disregard any subjects that are extracurricular, that is, if you have taken a course that is not in the curriculum of your course.
To contextualize, I have the following rules that I have already created, but I do not think it will be necessary, just the rules I have already mentioned:
curso(CODIGOCURSO,NOMECURSO).
materia(CODIGOMATERIA,NOMEMATERIA,CREDITOSMATERIA).
curriculo(CODIGOCURSO,[CODIGOMATERIA1,CODIGOMATERIA2,...,CODIGOMATERIAn).
aluno(RA,NOME).
cursa(RA,CODIGOCURSO).
historico(RA,[ITEM1,ITEM2,...,ITEMn). (como mostrei anteriormente).
pertence_curso(M,C):-curriculo(C,Lista),member(M,Lista).