fix polynomial to accept any exponents

This commit is contained in:
hugogogo
2026-05-04 22:14:12 +02:00
parent bc48f52c2c
commit 7f06d505d1
7 changed files with 86 additions and 61 deletions

View File

@@ -16,31 +16,30 @@ this project uses submodules (maybe recursively), so either :
## steps
1. lexer
-> tokens[] :
{
PLUS -> +
MINUS -> -
VARIABLE -> x
NUMBER -> int or double
POWER -> ^
MULTIPLICATION -> *
DIVISION -> /
END -> null
}[]
-> tokens types :
- TOKEN_VARIABLE // x, y, etc.
- TOKEN_NUMBER_INT // int
- TOKEN_NUMBER_DOUBLE // double
- TOKEN_POWER // ^ or **
- TOKEN_SIGN_PLUS // +
- TOKEN_SIGN_MINUS // -
- TOKEN_FACTOR_MULT // *
- TOKEN_FACTOR_DIV // / or :
- TOKEN_EQUAL // =
- END // null
2. parser
-> terms[] :
{
SIGN -> + or -
COEFFICIENT -> double
EXPONENT -> double
}[]
-> terms :
- POSITION // left or righ from =
- SIGN // + or -
- COEFFICIENT // double
- EXPONENT // double
3. reduce
-> polynom :
{
a -> double
b -> double
c -> double
}[]
-> polynom :
- 0
- 1
- 2
- 3
- ...
4. print reduced form
5. find degree
6. print degree