level 1
lxtnick
楼主
Write a Prolog program for the following problem
Implement in Prolog the shunting algorithm as described in the lecture for converting an expression in
infix notation into postfix notation. For examples, the goals
shunt([‘(‘,2,+,3,’)’,*,4],X) will return X=[2,3,+,4,*]
shunt([35,-,5,*,4,+,2],X) will return X=[35,5,4,*,-,2,+].
shunt([‘(‘,a,+,b,’)’,*,c],X) will return X=[a,b,+,b,*]
More test cases should be used to demonstrate the working of the program.
2010年04月02日 02点04分
1
Implement in Prolog the shunting algorithm as described in the lecture for converting an expression in
infix notation into postfix notation. For examples, the goals
shunt([‘(‘,2,+,3,’)’,*,4],X) will return X=[2,3,+,4,*]
shunt([35,-,5,*,4,+,2],X) will return X=[35,5,4,*,-,2,+].
shunt([‘(‘,a,+,b,’)’,*,c],X) will return X=[a,b,+,b,*]
More test cases should be used to demonstrate the working of the program.