Consider rewriting find_all_avgs/3 as a typical recursive predicate (Base case + recursive step) The base case would be when the first parameter (the list of students) is an empty list. In this case the result would be also an empty list. The recursive step clasuse would be one that takes the head of the input list, computes the student average for that student and then computes the rest of the averages (recursion).
Note that the computed average can be put as the head of the output list instead of using append/3.
Consider rewriting find_all_avgs/3 as a typical recursive predicate (Base case + recursive step) The base case would be when the first parameter (the list of students) is an empty list. In this case the result would be also an empty list. The recursive step clasuse would be one that takes the head of the input list, computes the student average for that student and then computes the rest of the averages (recursion).
Note that the computed average can be put as the head of the output list instead of using append/3. So, the resulting predicate would be something like: find_all_avgs(,_,). % Base case find_all_avgs(Head|Tail,Year,Head,Avg|L):- find_student_avg(Head,Year,Avg), find_all_avgs(Tail,Year,L).
% Recursion step This predicate yields results of the form L= Student1,Average1, ...., StudentN,AverageN which is not what you stated. However, I believe that would be the proper output format. If you really need the other output format then the head of the second clause should be find_all_avgs(Head|Tail,Year,Head|Avg|L).
Thx! This works fine for me! – Olga Anastasiadou Mar 23 at 14:24 Any idea on how to sort this list by avg?
– Olga Anastasiadou Mar 23 at 15:41 Check keysort/2. You will have to build a list of Key-Value pairs though... – gusbro Mar 23 at 16:15 thx. I 'll check this out – Olga Anastasiadou Mar 23 at 16:20.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.