how to match a predicate converting digits to words with a given fact in prolog

Viewed 56

I want to make this example : gradeInWords(stud04,'Database',translate). = [five,nine] tried this code to print a student grade at specific course in words, i cant link between the fact and the code as i am new to prolog and i cant figure out how to do that or what to add to code so it work well the fact is student(stud04,'Database',59).

code :

totext(0, zero).
totext(1, one).
totext(2, two).
totext(3, three).
totext(4, four).
totext(5, five).
totext(6, six).
totext(7, seven).
totext(8, eight).
totext(9, nine).

gradeInWords(Student, Course, translate) :-
   translate([], []).

translate([Head|Tail], [TranslatedHead|TranslatedTail]) :-
   totext(Head, TranslatedHead),
   translate(Tail, TranslatedTail).
0 Answers
Related