From 5f3d507b92931b5a2d43a7b6e820aa86a3b6b86c Mon Sep 17 00:00:00 2001 From: Divyansh Prakash Date: Thu, 2 Nov 2023 22:01:11 +0530 Subject: [PATCH] Add example in loop.js --- src/loop.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/loop.js b/src/loop.js index c94c927..d78aaf0 100644 --- a/src/loop.js +++ b/src/loop.js @@ -18,6 +18,18 @@ function loop(init, f) { return res; } +/* example: +=========== +let fact5 = loop({ n: 5, f: 1}, ({ n, f }) => { + if (n < 2) + return f; + return recur({ + n: n - 1, + f: f * n + }); +}); +*/ + module.exports = { loop, recur