Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #8915
| From | Chad <cdalten@gmail.com> |
|---|---|
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: prefix notation question |
| Date | 2011-10-17 07:50 -0700 |
| Organization | http://groups.google.com |
| Message-ID | <0135959f-5846-4869-9c5a-dd08998015e9@u13g2000vbx.googlegroups.com> (permalink) |
| References | (1 earlier) <BZGdnRzdc-qLOAbTnZ2dnUVZ_vydnZ2d@posted.palinacquisition> <0142e456-9e9a-4f71-adaa-5ea9cad35427@u9g2000vby.googlegroups.com> <qotbotg5c7i.fsf@ruuvi.it.helsinki.fi> <7889cbdf-4b32-413f-bae0-daea3814e85a@f13g2000vbv.googlegroups.com> <ae7f17fd-8825-4c5c-a185-0abed998aea5@a12g2000vbz.googlegroups.com> |
On Oct 17, 7:45 am, Chad <cdal...@gmail.com> wrote: > On Oct 17, 7:39 am, Chad <cdal...@gmail.com> wrote: > > > > > > > On Oct 17, 12:06 am, Jussi Piitulainen <jpiit...@ling.helsinki.fi> > > wrote: > > > > Chad <cdal...@gmail.com> writes: > > > > On Oct 16, 8:46 pm, Peter Duniho <NpOeStPe...@NnOwSlPiAnMk.com> wrote: > > > > > On 10/16/11 8:15 PM, Chad wrote: > > > > > > > I'm supposed to write a program that calculates arithmetic expressions > > > > > > using prefix notation. The one example our professor gave us is > > > > > > > (+ (- 6) (* 2 3 4) (/ (+ 3) (* 1) (- 2 3 1))) > > > > > > > Which evaluated sucessively becomes.. > > > > > > > (+ (- 6) (* 2 3 4) (/ 3 1 -2)) //<----I don't see how he arrives at > > > > > > this expression > > > > > > (+ -6 24 -1.5) > > > > > > 16.5 > > > > > > > I don't see how he gets (+ (- 6) (* 2 3 4) (/ 3 1 -2)) from (+ (- 6) > > > > > > (* 2 3 4) (/ (+ 3) (* 1) (- 2 3 1))) > > > > > > Ask your professor. > > > > > I did. He told me to come by during his office hours. I told him I > > > > couldn't because of work. He hasn't responded back. > > > > > Chad > > > > In (/ 3 1 -2), divided 3 by 1 and -2. Similarly in (- 2 3 1), subtract > > > 3 and 1 from 2. This is the rule for two or more arguments to / and -. > > > > With one argument, like in (- 6), the rule is different and the > > > notation means the appropriate inverse: additive inverse in case of -, > > > multiplicative in case of /. > > > > The languages that use this notation tend to like -3/2 (an exact > > > rational computed from exact rationals) more than -1.5 (typically an > > > approximation). > > > But what happened to the (*3) that was in the original arithemtic > > expression? > > I mean, what happened to (+3)? This obviously has to be account for > somewhere. > Never mind. I was one again experiencing a brain lapse. Chad.
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar
prefix notation question Chad <cdalten@gmail.com> - 2011-10-16 20:15 -0700
Re: prefix notation question Peter Duniho <NpOeStPeAdM@NnOwSlPiAnMk.com> - 2011-10-16 20:46 -0700
Re: prefix notation question Chad <cdalten@gmail.com> - 2011-10-16 20:58 -0700
Re: prefix notation question Peter Duniho <NpOeStPeAdM@NnOwSlPiAnMk.com> - 2011-10-16 23:38 -0700
Re: prefix notation question Jussi Piitulainen <jpiitula@ling.helsinki.fi> - 2011-10-17 10:06 +0300
Re: prefix notation question Chad <cdalten@gmail.com> - 2011-10-17 07:39 -0700
Re: prefix notation question Chad <cdalten@gmail.com> - 2011-10-17 07:45 -0700
Re: prefix notation question Chad <cdalten@gmail.com> - 2011-10-17 07:50 -0700
Re: prefix notation question Jussi Piitulainen <jpiitula@ling.helsinki.fi> - 2011-10-17 18:10 +0300
Re: prefix notation question Chad <cdalten@gmail.com> - 2011-10-18 15:30 -0700
Re: prefix notation question Roedy Green <see_website@mindprod.com.invalid> - 2011-10-18 19:40 -0700
Re: prefix notation question Roedy Green <see_website@mindprod.com.invalid> - 2011-10-18 19:36 -0700
csiph-web