开发者

Unwrapping a formula?

In my ongoing quest to learn ruby by doing training exercises I came across开发者_Python百科 an extra credit question that basically wants me to unwrap this formula:

what = add(age, subtract(height, multiply(weight, divide(iq, 2))))

My question is I am a little stuck on this part. I understand for example that add(age, subtract would be the same as age + subtract, but after that I just become lost.


Keep going, but work from the inside-out instead--what's divide(iq, 2)? Use that as the second argument for multiply, and so on.


Start from the inside and work out.

Divide iq by 2. Multiply that by weight. Subtract that from height. Add that to age.

In general, with nested parentheses, you always start from the innermost.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜