I do random things from time to time.
You'll probably find me programming.
License: MIT License
What should happen when a negative count is passed? Currently it is vague to me, and the behavior I may expect is not what happens. Instead the current behavior is:
local tbl = {1, 2, 3, 4, 5}
table.shift(tbl, 4, -2)
outputs:
{
[1] = 1,
[2] = 4,
[3] = 5,
[4] = 4,
[5] = 5,
}
Or an error should be raised for those inputs if not documented.
approxeqabs(1 + (1 * math.epsilon), 1)
is returning false
when it seems like it should be true. See the equivalent Zig test.
Haven't looked into this one just yet but it seems fairly identical to the Zig code, assuming @fabs
is doing what I am expecting it does.
P.S. the comparison in approxeqabs should be <=
not <
as well.
Oops, seems like that <
comparison was actually the cause, I thought it wasn't because I ran the wrong test.
A note should be added about the behavior of functions that operate on the array portion of a table that has holes, either defining a specific behavior or (since all of them use ipairs or #
) document that the behavior is undefined/follows that of ipairs.
Those functions are table.reduce
, table.reverse
, table.join
, table.randomipair
and table.randomvalue
.
Trying to do math.approxeqrel(math.root(-64, 3), -4)
yields false
.
On line 142 it seems like it was suppose to be:
tolerance = tolerance or math.sqrt(ext_math.epsilon)
On line 149 shouldn't the comparison be <=
, just in case?
Printing out the left and right half of the comparison with the above example yields:
math.abs(a - b): 4.4408920985006e-16
math.max(a, b) * tolerance: -8.8817841970013e-16
I suppose line 149 should be:
return math.abs(a - b) <= math.abs(math.max(a, b)) * tolerance
which seems to work, in this example at least
It is documented in string.cjust
that it will not overshoot final_len
when given a multi-byte pattern, although that is incorrect.
print(string.cjust("foo", 4, '123')) ---> "foo123"
The previous code will result in a string that has the length 6
, while the provided final_len
was 4
. Is that not what the documentation meant?
It should be documented what behavior to expect if dest
was the same table as the tbl
argument, such as in:
local tbl = {1, 2, 3}
table.reverse(tbl, tbl)
Currently, it seems like it isn't supported, so that should be documented.
The standard table.sort()
sorts a table in-place and doesn't return anything, which is an annoyance whenever the table needs to also be modified in some way either prior to or after sorting. For example, compare the following:
local function sortedKeys(tbl)
local keys = table.keys(tbl)
table.sort(keys)
return keys
end
-- vs
local function sortedKeys(tbl)
return table.sort(table.keys(tbl))
end
Not only is the second snippet considerably shorter, but it is also slightly easier to read. I come across these kinds of use cases fairly often and so I think it's a worthwhile issue to address.
Overriding table.sort
isn't a good idea, but I'm lost on as to what to name a function that would have the same behaviour as the stock one but returns the sorted table. table.sort2
could work may be confusing, and table.sorted
implies a copy.
sign should probably do type checking so it does not return 0
on say strings.
sign should check for NaN
so it does not return 0
when it is not actually that.
Could be simply made:
function ext_math.sign(n)
if n > 0 then
return 1
elseif n < 0 then
return -1
elseif n == 0 then
return 0
end
end
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.