Skip to content

Adding arithmetic computation: Power.#6

Open
GBT3101 wants to merge 3 commits into
ronami:masterfrom
GBT3101:master
Open

Adding arithmetic computation: Power.#6
GBT3101 wants to merge 3 commits into
ronami:masterfrom
GBT3101:master

Conversation

@GBT3101

@GBT3101 GBT3101 commented Aug 10, 2020

Copy link
Copy Markdown

Hey Ronen, I wish to support the meta-typing effort by adding a new arithmetic computation!

Comment thread README.md Outdated
- [Subtract](src/subtract/index.d.ts) - subtracts two numbers.
- [Multiply](src/multiply/index.d.ts) - multiplies two numbers.
- [Divide](src/divide/index.d.ts) - divides two numbers.
- [Power](src/power/index.d.ts) - computes A power B.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about computes the given base taken to the power of the given exponent?

Comment thread src/power/index.d.ts Outdated
@@ -0,0 +1,32 @@
import { Multiply, Dec, Cast } from '..';

// Power two numbers: https://lodash.com/docs/4.17.15#power.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this can be the same description as in the README.md. Also, this URL doesn't lead anywhere, how about we use https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/pow instead?

Comment thread src/power/index.d.ts Outdated
// This type uses recursive (and not officially supported) type alias, see more:
// https://github.com/microsoft/TypeScript/issues/26223#issuecomment-513187373.
export type Power<
// The first number in a multiplication.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think multiplication is a mistake, how about The base number?

Comment thread src/power/index.d.ts
// https://github.com/microsoft/TypeScript/issues/26223#issuecomment-513187373.
export type Power<
// The first number in a multiplication.
A extends number,

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this can be B (short for base).

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it breaks the consistency of other arithmetic computations in the project where A is always the first number of the evaluation (like in normal calculators)

Comment thread src/power/index.d.ts Outdated
export type Power<
// The first number in a multiplication.
A extends number,
// The second number in a multiplication.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is a mistake too, how about The exponent used to raise the base?

Comment thread src/power/index.d.ts
// The first number in a multiplication.
A extends number,
// The second number in a multiplication.
B extends number

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this can be E (short for exponent).

@ronami ronami left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR 🏆, please see my comments 🙏

@GBT3101

GBT3101 commented Aug 27, 2020

Copy link
Copy Markdown
Author

@ronami I made the needed changes :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants