From 3e7432a9086ca238c36599eec764e8251062ae21 Mon Sep 17 00:00:00 2001 From: henz Date: Sun, 30 Jun 2024 14:54:58 +0800 Subject: [PATCH] fixes #796 --- xml/chapter3/section1/subsection3.xml | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/xml/chapter3/section1/subsection3.xml b/xml/chapter3/section1/subsection3.xml index d371b55e0..101b341e2 100644 --- a/xml/chapter3/section1/subsection3.xml +++ b/xml/chapter3/section1/subsection3.xml @@ -1091,22 +1091,20 @@ paul_acc("withdraw", "rosebud")(50); // Withdraws 50, should return 40 exercise_3_8_solution_example -function make_f(init) { - return x => { - init = x - init; - return init; - }; +let v = -0.5; +function f(x) { + v = x + v; + return v; } - -const f = make_f(1/2); exercise_3_8_solution_example -display(f(1) + f(0)); -display(f(0) + f(1)); +// try these separately +display(f(0) + f(1)); // returns 0 +display(f(1) + f(0)); // returns 1