-
-
Notifications
You must be signed in to change notification settings - Fork 113
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(stdlib): Add Number.tan
, Number.factorial
, Number.clamp
, Number.lerp
#1373
Conversation
Number.tan
, Number.factorial
, Number.clamp
, Number.lerp
, Number.map
- Undo Changes To GitIgnore - Update Doc Versions - Update Docs On Lerp
Rewrite Number.Factorial To Use Recurrsion
I made the changes we talked about in discord i will move |
Number.tan
, Number.factorial
, Number.clamp
, Number.lerp
, Number.map
Number.tan
, Number.factorial
, Number.clamp
, Number.lerp
Co-authored-by: Blaine Bublitz <blaine.bublitz@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm having some issues with this stuff.
/** | ||
* Computes the factorial of a number. | ||
* | ||
* @param input: The number to compute the factorial of, Must be a Non negative integer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* @param input: The number to compute the factorial of, Must be a Non negative integer | |
* @param input: The non-negative integer used to compute the factorial |
*/ | ||
export let factorial = input => { | ||
// Error If It is Negative, or Not an Integer | ||
if (sign(input) is -1 || isInteger(input)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (sign(input) is -1 || isInteger(input)) { | |
if (input < 0 || isInteger(input)) { |
this is better, right?
export let factorial = input => { | ||
// Error If It is Negative, or Not an Integer | ||
if (sign(input) is -1 || isInteger(input)) { | ||
fail "Factorial Expects A Non Negative Integer Input" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we actually want to fail or return an option? @ospencer
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should fail. If we really don't want it to fail then we can take Jake's suggestion to define this as the gamma function for non-integers.
fail "Factorial Expects A Non Negative Integer Input" | ||
} else { | ||
// Factorial Helper | ||
let rec fact = n => if (n is 0) 1 else n * fact(n - 1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let rec fact = n => if (n is 0) 1 else n * fact(n - 1) | |
let rec fact = n => if (n == 0) 1 else n * fact(n - 1) |
why use is
?
* @param min: The minimum value in the range | ||
* @param max: The maximum value in the range |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did someone say Range?
* | ||
* @since v0.5.3 | ||
*/ | ||
export let lerp = (start: Number, end: Number, amount: Number) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
export let lerp = (start: Number, end: Number, amount: Number) => { | |
export let linearInterpret = (start: Number, end: Number, amount: Number) => { |
Hear me out. lerp
sounds like I'm 🤮
* | ||
* @param start: The starting value | ||
* @param end: The ending value | ||
* @param amount: an amount between 0 and 1, anything outside the range will produce an extrapolation i.e `lerp(0, 100, 2)` will produce 200 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is a "interpolation" but you are saying that it also "exptrapolates". I don't like that.
can someone convert this to a draft pr until #1404 is completed |
I think i am going to close this as it will require an entire rewrite to use range and the scope of this pr has changed to just be |
This pr adds
Number.tan
,Number.factorial
,Number.clamp
,Number.lerp
to the Number libary for #1017