Arithmetic evaluation: Difference between revisions

→‎{{header|Prolog}}: works with swipl + lang tag
m (→‎{{header|Python}}: Another case problem)
(→‎{{header|Prolog}}: works with swipl + lang tag)
Line 1,276:
 
=={{header|Prolog}}==
{{works with|SWI Prolog}}
% Lexer
<lang prolog> % Lexer
numeric(X) :- 48 =< X, X =< 57.
not_numeric(X) :- 48 > X ; X > 57.
Line 1,294 ⟶ 1,295:
lex2([Xa,Xb|Xs], [Xa|Ys]) :- number(Xa), atom(Xb), lex2([Xb|Xs], Ys).
lex2([Xa,Xb|Xs], [Y|Ys]) :- number(Xa), number(Xb), N is Xa * 10 + Xb, lex2([N|Xs], [Y|Ys]).
% Parser
Line 1,326:
% Example use
% calculator("(3+50)*7-9", X).</lang>
 
 
=={{header|Python}}==