This post is extention of my last post
motivation
I have had quite the experince with mathematical projects like (perlin noise, cryptography and statistics) now those topics are already challenging last thing you would want, is if something is missing…
So i made my last post to speak about it and thanks to a comment. I thought why not make another post not about me and my opinions, but about your experiences with roblox math challenges and what would you have wanted for the math libary to have. That would have made it easier on you.
The purpose of this is to talk about it so someone may take notice and request for it in rfcs github page i will be doing that myself but, I am not experienced with github so my request may take longer.
Requests that i have made:
function math.sum(…: number) → number
Status: Not implemented
A fundemental function who adds numbers together and returns it, very useful when the
numbers are vardiac and the values are not known in advanced.
Before:
local total = 0
for _, num in {string.byte("123", 1, 3)} do
total += num
end
print(total) --> 150
After:
function math.sum(...: number) : number
local total = 0
for _, num in {...} do
total += num
end
return total
end
print(math.sum(1,2,4,6)) --> 13
print(math.sum(table.unpack({5, 5, 3, 2})) --> 15
print(math.sum(string.byte("123", 1, 3)) --> 150
Pros:
globalization of math.sum no more repetition of code,
improves readability and less prone to errors,
potential optimizations.
Cons:
Introduces another function to the math library.
function math.avg(…: number) : number
Status: Not implemented
Another fundamental function that takes in number vardiacts and returns
the avarage of them all.
Before:
local total= 0
for _, num in {string.byte("123", 1, 3)} do
total += num
end
local avg = total/#{string.byte("123", 1, 3)}
print(avg) --> 50
After:
function math.avg(...: number) : number
-- without using math.sum function
local total = 0
for _, num in {...} do
total += num
end
return total/#{...}
end
print(math.avg(1,2,4,6)) --> 3.25
print(math.avg(table.unpack({5, 5, 3, 2})) --> 3.75
print(math.avg(string.byte("123", 1, 3)) --> 50
Pros:
globalization of math.avg no more repetition of code,
improves readability and less prone to errors,
potential optimizations.
Cons:
Introduces another function to the math library.
etc
Question: numbers are infinite does that mean the same for operational functions like those ?
My friends those are only 2 of my most used and also requested by some members of the ecosystem.
So what are your thoughts do you think there are other useful functions that are also fundemental, that should be taken into consideration?