开发者

SICP Exercise 1.2

开发者 https://www.devze.com 2023-03-31 09:37 出处:网络
I\'m having a hard time with exerc开发者_StackOverflowise 1.2 in SICP. Translate the following to prefix form:

I'm having a hard time with exerc开发者_StackOverflowise 1.2 in SICP.

Translate the following to prefix form:

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

Here's what I have, and I can't figure out why it doesn't work. What am I missing?

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


(-6 2)

Here you're trying to call -6 with 2 as its argument, which doesn't work of course as -6 is not a function. You rather want to call the - function with 6 and 2 as its arguments.

tl;dr: You forgot a space between - and 6.


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

精彩评论

暂无评论...
验证码 换一张
取 消