打印仅打印未绑定的变量,例如`_869`

时间:2019-04-27 04:40:19

标签: prolog sum

:- dynamic 
    course/6, 
    year/1, 
    sem/1, 
    code/1, 
    prereq/4, 
    credit_t/3, 
    courselist/7.    

course(1,1,'TMF1414','Introduction to Programming',4,'None').    
course(1,1,'TMF1814','Discrete Mathematics',4,'None').    
course(1,1,'TMF1014','System Analysis and Design',4,'None').    
course(1,2,'TMF1874','Mathematics For Computing',4,'None').    
course(1,2,'TMF1254','Communcation and Computer Network',4,'None').    
course(1,2,'TMF1434','Data Structure and Algorithms',4,'TMF1414,TMF1814').

consult:-
    write('Which year are you in?'),
    read(Year),nl,
    write('Which semester are you in?'),
    read(Sem),course(Year,Sem,_,_,_,_),nl,
    write('Welcome to '),
    write('Year: '),write(Year),
    write(' Semester:'),write(Sem),nl,nl,
    credit_t(Year,Sem,TotalCredit),write(TotalCredit),nl;menu.

credit_t(Year, Sem, TotalCredit):-
    courselist(course,Year, Sem, _,_,Credit,_), 
    sumlist(Credit,TotalCredit);
    write('Total credit you need to take for this year is ').

我能知道为什么今年所需的Total credit的产出没有总计吗? 它只是打印出_869

0 个答案:

没有答案