Skip to content

Commit

Permalink
Update wtse_prelude.lua
Browse files Browse the repository at this point in the history
- Deprecates Prelude's maxAbsFromTable() and adds math.max_abs()
- Removes WIP comment
  • Loading branch information
nuoun authored Dec 3, 2024
1 parent 3dc58a3 commit a7afc60
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/lua/wtse_prelude.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit a7afc60

Please sign in to comment.