SICP Exercise 1.2
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)))
加载中,请稍侯......
精彩评论