Extra Table Functions
Posted: Thu Jun 21, 2018 2:26 pm
I like extending the options available in the included table functions to make certain behaviors easier to accomplish. And since I already have them on hand, I might as well share them, in case anyone else has a use for them.
This function lets you use table functions as methods of whatever table you pass it. Also, if you pass it multiple arguments, it forms them into a table that can be used this way and returns it. This will preserve the existing metatable for the table you pass it, if there is on, changing only the __index element.
This one rounds down.
This function lets you use table functions as methods of whatever table you pass it. Also, if you pass it multiple arguments, it forms them into a table that can be used this way and returns it. This will preserve the existing metatable for the table you pass it, if there is on, changing only the __index element.
The next three functions all let you use indexes not actually in the table, rounding down, up, or to the closest existing index, and returning the associated value. This will preserve the existing metatable for the table you pass it, if there is on, changing only the __index element.
This one rounds down.
This rounds up.
And this rounds to the nearest.
More additions are likely to follow.