計算機科学のブログ

Building Abstractions with Functions - The Elements of Programming - Conditional Expressions and Predicates - translating

Structure and Interpretation of Computer Programs: JavaScript Edition(Harold Abelson(著)、Gerald Jay Sussman(著)、Julie Sussman(著)、The MIT Press)のChapter 1(Building Abstractions with Functions)、1.1(The Elements of Programming)、1.1.6(Conditional Expressions and Predicates)、Exercise 1.2の解答を求めてみる。

コード

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

console.log(expr)

入出力結果(Terminal, Zsh)

% node answer1.2.js 
-0.24666666666666667
%