From 452c6b7106f5795714083a84d81d3bc439e7e544 Mon Sep 17 00:00:00 2001 From: Martin Henz Date: Wed, 3 Jul 2024 07:36:36 +0800 Subject: [PATCH] fixes #796 (#1009) --- 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