From a7afc60d72faa54ef64e0e3f8b500065a5727ea4 Mon Sep 17 00:00:00 2001 From: nuoun <10226424+nuoun@users.noreply.github.com> Date: Tue, 3 Dec 2024 22:49:21 +0100 Subject: [PATCH] Update wtse_prelude.lua - Deprecates Prelude's maxAbsFromTable() and adds math.max_abs() - Removes WIP comment --- src/lua/wtse_prelude.lua | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/lua/wtse_prelude.lua b/src/lua/wtse_prelude.lua index 16645947767..ac07699fb22 100644 --- a/src/lua/wtse_prelude.lua +++ b/src/lua/wtse_prelude.lua @@ -44,7 +44,7 @@ function math.range(a, b) end --- WTSE MATH FUNCTIONS - NON-FINAL AND WIP +--- WTSE SPECIFIC MATH FUNCTIONS --- -- returns a table with the cumulative product of the elements in the input table @@ -89,6 +89,16 @@ function math.logspace(start_point, end_point, num_points) end -- returns the maximum absolute value found in the input table +function math.max_abs(t) + local o = 0 + for i = 1, #t do + local a = math.abs(t[i]) + if a > o then o = a end + end + return o +end + +-- deprecated: use math.max_abs() instead function math.maxAbsFromTable(t) local o = 0 for i = 1, #t do