Am Mo, den 06.12.2004 schrieb Chad Crabtree um 14:05:
> Bob Gailer wrote:
>
> > For grins I just wrote one that takes '1 2.3 - 3 4 5 + * /' as
> input
> > and prints -0.0481481.... 8 lines of Python. That indeed is less
> than
> > 100. Took about 7 minutes to code and test.
>
> I'm quite interested in seeing the sourcecode for that.
Well, I'm down to 12 lines:
import operator, sys
st = []
while 1:
s = raw_input("%s>" % [str(x) for x in st]).split()
if not s: break
for t in s:
func = {'+':operator.add, '-':operator.sub, '*':operator.mul,
'/':operator.div}.get(t, None)
if func is None:
st.append(float(t))
else:
sec = st.pop()
fir = st.pop()
st.append(func(fir, sec))Andreas
signature.asc
Description: Dies ist ein digital signierter Nachrichtenteil
_______________________________________________ Tutor maillist - [EMAIL PROTECTED] http://mail.python.org/mailman/listinfo/tutor
