Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Prefix Notation

Name: Anonymous 2007-11-08 19:06

I could do with some prefix notation practice (I have not reached Satori).

To this end, I'd be terribly obliged if you could post some nested mathematical expressions with nested brackets and only simple (+ - * /) operators, so I can practice converting them.

I'd also be obliged if you could tell me if I'm right/advise me where I'm going wrong.

An example;
7(8 x 9(10 x 3(8 + 4)))
(* 7 (* 8 (* 9 (* 10 (* 3 (+ 8 4 ) ) ) ) ) )

Am I right? Wrong? Advice?

Name: Anonymous 2007-11-08 19:58

>>2
So, technically right, just need to clean it up? Thank you very much :D

A supportive IRC-er gave me a monster one to solve - namely
(6(9-8*2(4-5)+7-4(2*3)+4-8))/(5(3(7-3)(2+1)-8+9-4))

With my shitty, uncleaned-up code, I got
(* 6 (+ (- 9 (+ (* 8 2 (- 4 5 ) ) 7 (* (- 4 (* 2 3 ) ) ) 4 (- 8 ) ) ) ) (/ (* 5 (* 3 (+ (- 7 3 ) (+ 2 1 ) (- 8 ) 9 (- 4 ) ) ) ) ) )

Let me just clean it up and I should be able to figure out if I'm right - the REPL says the answer is 12/5

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List