rhai-sci
rhai-sci copied to clipboard
Add `rem` function
Greetings 👋 I'd love to contribute
I'm working on rem, mod and idivide. The solution is easily extendable to other basic operations with similar format. For example, it could be extended to addition.
The behavior expectations are not very clear to me. For now, I used "Inputs with Compatible Sizes" > "2-D Inputs" section from this site as the reference. The 2 inputs can be numbers or number matrices, and the output is a float or a float matrix. For example:
rem(5, 3) == 2.0
rem([[1.0], [5.0], [11]], [[3, 8.0]]) == [[1.0, 1.0], [2.0, 5.0], [2.0, 3.0]]
The solution does not currently work with any inputs that are not specified in the section. For example, 1D arrays:
rem([3.0, 4.0, 5.0], 2.0) // error
Is this ok? I can make changes 🙂
Your contributions are very welcome! Please feel free to start a draft PR for #55, #56, and #57.
You're right that there aren't clear expectations around behavior as this project was a bit ad hoc to begin with. I think the "2-D Inputs" section that you identified is a good standard to target for further development.