Exercise 1.2

Pre-exercise Theory

Prefix Form is the "convention of placing the operator to the left of the operands".

One advantage of this form is that it can take any amount of arguments without any ambiguity:

(+ 42 77 12)

The other advantage is that nesting operations are also simple and unambiguous:

(+ 42 (- 77 12))

A good way of formatting prefix operations is by aligning the operands of an expression vertically, so that by looking at the indentation one can follow which operations go together:

; without pretty-print
(+ (* 3 (+ (* 2 4) (+ 3 5))) (+ (- 10 7) 6))

; with pretty-print
(+ (* 3
      (+
          (* 2 4)
          (+ 3 5)
      )
    )
   (+ (- 10 7)
      6
   )
)

## Problem

> Translate the following expression into prefix form:

5 + 4 + (2 - (3 - (6 + 4/5)))

    3(6 - 2)(2 - 7)

The total of this division is = -0.246 or -37/150

```scm
(/ (+ 5 4 (- 2 (- 3 (+ 6 (/ 4 5))))) (* 3 (- 6 2) (- 2 7)))
; -37/150

; pretty-print format:


(/ 
    (+ 5
       4
       (- 2
          (- 3
             (+ 6
                (/ 4 5)
             )
          )
       )
    )
    (* 3
       (- 6 2)
       (- 2 7)
    )
)