Prolog:存在错误

时间:2016-12-05 03:56:07

标签: prolog

我正在使用下面的prolog代码遇到存在错误。当然不是prolog的专家,但为什么程序不被认可?

任何想法或建议都将受到高度赞赏。

编制过程:

  1. gprolog test.pl
  2. [测试]。
  3. : - foo(P,S,B,O,M)。
  4.   

    未捕获的异常:错误(exist_error(procedure,(+)/ 2),foo / 5)

    代码:

    foo(P, S, B, O, M):-     
        % Pepperoni at weight 4 each
    
        member(P,[0,1,2,3,4,5,6,7,8,9,10]),
    
    
        % Sausage at weight 10 each
    
        member(S,[0,1,2,3,4]),
    
    
        % Bacon at weight 6 each
    
        member(B,[0,1,2,3,4,5,6]),
    
    
        % Onion at weight 5 each
    
        member(O,[0,1,2,3,4,5,6,7,8]),
    
    
        % Mushroom at weight 7 each
    
        member(M,[0,1,2,3,4]),
    
    
        % next figure out the pizza weight
        4*P + 10*S + 6*B + 5*O, 7*M,
        S =< 40, 
    
        % calculate remaining pepperoni if weight is low
        P is 40 - S. 
    

0 个答案:

没有答案