From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail1.wpi.edu ([130.215.36.102]) by speech.braille.uwo.ca with esmtp (Exim 3.35 #1 (Debian)) id 19PWer-00034a-00 for ; Mon, 09 Jun 2003 20:06:37 -0400 Received: from mcafee.wpi.edu (mcafee.WPI.EDU [130.215.36.86]) by mail1.WPI.EDU (8.12.10.Beta0/8.12.10.Beta0) with SMTP id h5A06M4S010585 for ; Mon, 9 Jun 2003 20:06:22 -0400 Received: from smtp.WPI.EDU(130.215.36.186) by mcafee.wpi.edu via csmap id 15295; Mon, 09 Jun 2003 20:07:49 -0400 (EDT) Received: from ccc2.WPI.EDU (root@ccc2.WPI.EDU [130.215.36.146]) by smtp.WPI.EDU (8.12.10.Beta0/8.12.10.Beta0) with ESMTP id h5A06Lat011670 for ; Mon, 9 Jun 2003 20:06:21 -0400 Received: from ccc2.WPI.EDU (ender3rd@localhost [127.0.0.1]) by ccc2.WPI.EDU (8.12.10.Beta0/8.12.10.Beta0) with ESMTP id h5A06J99005836 for ; Mon, 9 Jun 2003 20:06:19 -0400 Received: from localhost (ender3rd@localhost) by ccc2.WPI.EDU (8.12.10.Beta0/8.12.10.Beta0) with ESMTP id h5A06HmO005833 for ; Mon, 9 Jun 2003 20:06:17 -0400 X-Authentication-Warning: ccc2.WPI.EDU: ender3rd owned process doing -bs Date: Mon, 9 Jun 2003 20:06:17 -0400 (EDT) From: Owen Patrick Smith To: speakup@braille.uwo.ca Subject: Re: ot: parsing math equations In-Reply-To: <000701c32ecc$a8d9adb0$691817cf@130SetBC01> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: speakup-admin@braille.uwo.ca Errors-To: speakup-admin@braille.uwo.ca X-BeenThere: speakup@braille.uwo.ca X-Mailman-Version: 2.0.11 Precedence: bulk Reply-To: speakup@braille.uwo.ca List-Help: List-Post: List-Subscribe: , List-Id: Speakup is a screen review system for Linux. List-Unsubscribe: , List-Archive: the parenthesies and order of operations makes infix notation a pain to parse automatically. Look into pre/post-fix notation. it looks wierd and takes a bit to get used to but its much easier to parse. If you insist on using infix try a series of regexps. Find the first set of parens and run the algorithm recursively on just the parenthsied statement. Once you've run out of parens to find then evaluate the highest priority operations. repeat until you've run finished the whole string. Basically if you're just trying to get some help with homework consider Maple, Mathematica or similar, its probably easier. HtH, Owen On Mon, 9 Jun 2003, Tyler Spivey wrote: > sorry if this's off topic, but here goes: > i'm writing a program in python to do varius math things. > factoring, radicals, etc. but my major limitation is that it can't > do anything with algebra equations. > 2x^2+3x+4x-x+3y > etc... > would a regular expression be the answer for breaking these down into there > component parts? > or do I need a full-blown parser for doing that? > probably the parser - but i'm not sure if any python based solutions exist. > they do, but I'm not sure if they are what i want. > i don't want to do any complex coding. this's just a spare-time project for > getting homework done faster, and i don't want to spend hours and hours on > it. it's currently topped almost 10k, but most of that are the docs > contained in one very long tripple-quoted string. > and all this coming from the guy who previously hated python without really > trying it first... > > > _______________________________________________ > Speakup mailing list > Speakup@braille.uwo.ca > http://speech.braille.uwo.ca/mailman/listinfo/speakup > > >