From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=0.2 required=5.0 tests=BAYES_00,INVALID_MSGID, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,cae702701e24ef29 X-Google-Attributes: gid103376,public From: "Howard W. LUDWIG" Subject: Re: Please read this..thank you Date: 1997/11/07 Message-ID: <346335F8.7B04@lmco.com>#1/1 X-Deja-AN: 287868028 References: <345BBEC0.1D12@upnaway.com> Organization: Lockheed Martin Electronics & Missiles Reply-To: howard.w.ludwig@lmco.com Newsgroups: comp.lang.ada Date: 1997-11-07T00:00:00+00:00 List-Id: Sho wrote: > > Dear Ada Programmers, > > Could you please help me with the algorithms on how to convert Infix to > a Postfix expression? examples: > > Infix: 1 + 2 + 3 > Postfix: 1 2 3 + + I do not know whether you were simply trying to put together a quick, simple example without paying close attention to what you were doing (and consequently made a silly mistake) or you have an actual misunderstanding which may cause you troubles in trying to compose appropriate code. However, your example is in error: While we all know that addition of integers (and, more generally, real and complex numbers) is associative, so that (1 + 2) + 3 = 1 + (2 + 3). However, most applications (APL being the only major exception I know) regard 1 + 2 + 3 as meaning (1 + 2) + 3 (which might be modified by application of commutative and associative principles to some other arrangement--note that Ada is restrictive regarding such rearrangements for floating point values due to the "non-real" floating-point model, so I am not being pedantic here; another example would be an operation, such as subtraction, which is nonassociative). Now, (1 + 2) + 3 is 1 2 + 3 + in infix whereas 1 + (2 + 3) is 1 2 3 + + in infix. > Sho Howard W. LUDWIG Working (but not speaking) for Lockheed Martin Electronics & Missiles Co.