From 8d6f1ade93fa269219f0446f7de8ac884728508b Mon Sep 17 00:00:00 2001 From: celeron55 Date: Thu, 29 Aug 2024 15:35:28 +0300 Subject: [PATCH] README.md: Return from example fold methods (#8) --- README.md | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 9d5254a..47ae77f 100644 --- a/README.md +++ b/README.md @@ -40,9 +40,10 @@ mymod.speed_monoid = player_monoids.make_monoid({ end, fold = function(tab) local res = 1 - for _, speed in pairs(tab) do + for _, speed in pairs(tab) do res = res * speed - end + end + return res end, identity = 1, apply = function(speed, player) @@ -108,9 +109,10 @@ newmod.speed_boosts = player_monoids.make_monoid({ end, fold = function(tab) local res = 1 - for _, speed in pairs(tab) do + for _, speed in pairs(tab) do res = math.max(res, speed) - end + end + return res end, identity = 1, apply = ??? @@ -202,4 +204,4 @@ global state. * The order that different effects get combined together is based on key order, which may not be predictable. So you should try to make your monoids commutative in addition to associative, or at least not care if the order of two changes -is swapped. \ No newline at end of file +is swapped.