我已经在Prolog中做了一个可操作的广义的语言algorithm求解器,但是它太慢了。 只需要8分钟即可运行简单的expression式SEND + MORE = MONE Y.有人可以帮助我使其运行得更快吗? /* verbalArithmetic(List,Word1,Word2,Word3) where List is the list of all possible letters in the words. The SEND+MORE = MONEY expression would then be represented as verbalArithmetic([S,E,N,D,M,O,R,Y],[S,E,N,D],[M,O,R,E],[M,O,N,E,Y]). */ validDigit(X) :- member(X,[0,1,2,3,4,5,6,7,8,9]). validStart(X) :- member(X,[1,2,3,4,5,6,7,8,9]). assign([H|[]]) :- validDigit(H). assign([H|Tail]) :- validDigit(H), assign(Tail), fd_all_different([H|Tail]). findTail(List,H,T) :- append(H,[T],List). convert([T],T) :- validDigit(T). convert(List,Num) :- […]