Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Too many lines of JavaScript code #663

Open
Emojigit opened this issue Nov 14, 2021 · 1 comment
Open

Too many lines of JavaScript code #663

Emojigit opened this issue Nov 14, 2021 · 1 comment

Comments

@Emojigit
Copy link

Emojigit commented Nov 14, 2021

Original

吾有一言。曰「「春日宴。」」。書之。
有數九。名之曰「酒數」。

恆為是。若「酒數」等於零者乃止也。

	吾有三言。曰「「與君」」。曰「酒數」。
		曰「「杯酒。可以窮歡宴。綠酒一杯歌一遍。」」。書之。

減「酒數」以一。昔之「酒數」者。今其是矣云云。

吾有一言。曰「「綠酒千杯腸已爛。」」。書之。

Compiled

var _ans1 = "春日宴。";
console.log(_ans1);
var 酒數 = 9;
while (true) {
  if (酒數 == 0) {
    break;
  };
  var _ans2 = "與君";
  var _ans3 = 酒數;
  var _ans4 = "杯酒。可以窮歡宴。綠酒一杯歌一遍。";
  console.log(_ans2, _ans3, _ans4);
  const _ans5 = 酒數 - 1;
  酒數 = _ans5;
};
var _ans6 = "綠酒千杯腸已爛。";
console.log(_ans6);

Improved

console.log("春日宴。");
let 酒數 = 9;
while (true) {
  if (酒數 == 0) {
    break;
  };
  console.log("與君", 酒數,"杯酒。可以窮歡宴。綠酒一杯歌一遍。");
  酒數 -= 1;
};
console.log("綠酒千杯腸已爛。");
@UltimatePea
Copy link

This might not be an improvement
because the compiled version is more similar to the A-Normal Form, which is easier for compilation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants