A little under two years ago, I started working on a little project we have here at NCSU. I should perhaps devote another blog entry to discussing that lovely little project... Anyway, there's a lot of Maple code in this project (as it is based in Maple), and I've had to untangle and understand what multiple programmers have done over the years. Last year, I came across one piece of code that I thought was exploiting a bug in Maple: We would take a long string of commands and parse the entire string with a single parse() command. I could never get a Maple worksheet to reproduce those results obtained from piping the command into Maple from the command line. Weird, no? After a good deal of poking and experimenting, it suddenly struck me: We're not parsing multiple commands. The programmer who wrote this bit of code wrapped the commands in an intelligent an unexpected way. So, over a year later, here I am to share with you a way to parse multiple lines with a single parse() command: Simply wrap it in a for ... do loop. Yes, that's it. The command parse() expects a single to be parsed. Maple interprets a for loop as a single line. It's just that easy. The following example should be illustrative. str := "a:=0 ; b:=2*Pi ; c:=exp(x)*cos(x) ; d:=int(c, x=a..b) ;"; parse( cat( "for A from 1 to 1 do ", str, "od;" ), statement ); --Schivnorr

Please Wait...