File indexing completed on 2024-04-21 03:41:33

0001 # -*- coding: utf-8 -*-
0002 import subprocess
0003 
0004 input="fib:=n->piecewise { eq(n,0)?0, eq(n,1)?1, ?fib(n-1)+fib(n-2) }\n"
0005 
0006 i=15
0007 for a in range(i,29):
0008     input += "fib(%d)\n" % (a)
0009 p = subprocess.Popen(["calgebra", "--calculate", "--print-time"], shell=False, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
0010 
0011 output=p.communicate(input)
0012 for line in output[1].split('\n'):
0013     theLine = line.split('time:')
0014     if len(theLine)>1:
0015         #print str(i)+", "+theLine[1]
0016         print theLine[1]
0017         i+=1
0018