Syntax error in Prolog regarding <> -
i have prolog code must calculate successor of number, number being represented in list. problem code generates "syntax error: operator expected" error on -n<>0 part of code. searched everywhere equivalent of <>, how find everywhere , how learned in class. should change fix error?
%successor of number represented on list %[1 9 3 5 9 9]-->[1 9 3 6 0 0] %domains % el=integer % list=el* %predicates % add_fn(el,list,list) % inverted(list,list) % succesor(list,list) % suc(list,list,integer) %clauses add_fn(e,[],[e]). add_fn(e,[h|t],[h|l]):-add_fn(e,t,l). inverted([],[]). inverted([h|t],l):-inverted(t,l1),add_fn(h,l1,l). succesor([],[]):-!. succesor(l,r):-inverted(l,lm),suc(lm,s,1),inverted(s,r). suc([],[],_):-!. suc([h|t],[h|l],n):-n=0,!,suc(t,l,0). suc([h|t],[m|l],n):-n<>0,!,s=h+n,m=s mod 10,n1=s div 10,suc(t,l,n1).
Comments
Post a Comment