Skip to content

Commit

Permalink
Merge pull request #16 from coco33920/add_logic
Browse files Browse the repository at this point in the history
Add logic
  • Loading branch information
vanilla-extracts authored Nov 15, 2023
2 parents f33024c + 78366c2 commit 44652a3
Show file tree
Hide file tree
Showing 14 changed files with 740 additions and 188 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "mini-calc"
version = "2.3.1"
version = "2.4.0"
license = "GPL-3.0-or-later"
description = "A minimalistic configurable rust calculator"
homepage = "https://calc.nwa2coco.fr"
Expand Down
61 changes: 46 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Calc

<div align="center">

**Calc: a minimalistic calculator built in rust for educational purpose only.**
Expand Down Expand Up @@ -48,13 +49,13 @@ Check [the website](https://calc.nwa2coco.fr) for more informations.
- [X] Parsing advanced operations
- [X] Parsing lpar,rpar
- [X] mathematical priority
- [X] Left priority
- [X] Right priority
- [X] Left priority
- [X] Right priority
- [X] parenthesis support
- [X] Assignment
- [X] associativity support
- [X] Left associativity
- [X] Right associativity
- [X] Left associativity
- [X] Right associativity
- [X] Application REPL
- [X] Add the REPL
- [X] basic REPL
Expand All @@ -66,24 +67,32 @@ Check [the website](https://calc.nwa2coco.fr) for more informations.
- [X] Advanced operation interpreter
- [X] Identifiers (variable) interpreter
- [X] Built-in
- [X] pi
- [X] pi
- [X] e
- [X] Config
- [X] Config colours
- [X] Config prompt
- [X] Add more operations
- [X] exponent
- [X] exponent
- [X] Add support for functions
- [X] exp
- [X] ln
- [X] log base a
- [X] cos/sin/tan
- [X] cosh/sinh/tanh
- [X] atan/acos/asin
- [ ] Add logic
- [ ] Add basic true/false
- [ ] Add binary operator
- [ ] Add unary operator
- [X] Add logic
- [X] Add basic true/false
- [X] Add binary operator
- [X] or (&&)
- [X] and (||)
- [X] `>=`
- [X] `>`
- [X] `<=`
- [X] `<`
- [X] `==`
- [X] Add unary operator
- [X] not (!)
- [ ] For later
- [ ] Defining your own functions
- [ ] Add RPN mode
Expand All @@ -105,10 +114,13 @@ Check [the website](https://calc.nwa2coco.fr) for more informations.

## Configuration

You can configure the general color, greeting message, greeting color, prompt and prompt color from the file for example in (for linux)
You can configure the general color, greeting message, greeting color, prompt and prompt color from the file for example
in (for linux)

```
~/.config/mini-calc/mini-calc.toml
```

Or situated in your operating system config folder.

### What the configuration looks like
Expand All @@ -118,6 +130,7 @@ The default configuration looks like this
![img.png](docs/assets/img.png)

### Colors

Available colors are

- purple
Expand All @@ -138,7 +151,7 @@ Configuration:

![img.png](docs/assets/config_modified.png)

It looks like:
It looks like:

![img.png](docs/assets/config_looks.png)

Expand All @@ -159,21 +172,23 @@ The following functions are available
- ln
- log (alias of ln)
- sqrt
- factorial (aliases: fact or !)
- factorial (aliases: fact)
- abs
- ceil
- floor
- round

### Trigonometry

For trigonometry, the input are assumed to be in radian, if not, you have to put "false" or "true" as second argument, example shown bellow
For trigonometry, the input are assumed to be in radian, if not, you have to put "false" or "true" as second argument,
example shown bellow

![img.png](docs/assets/trigo.png)

### Exp/ln

If you use the exp function you can pass a second argument for the base you are using, if no second arguments are passed this is assumed to be in natural base
If you use the exp function you can pass a second argument for the base you are using, if no second arguments are passed
this is assumed to be in natural base

![img.png](docs/assets/expln.png)

Expand All @@ -188,3 +203,19 @@ You can take the nth root with the sqrt function, by default it takes the second
You can round to the nth decimal with the round function, by default it round to the integer (floor)

![img.png](docs/assets/round.png)

## Logic

You can now use logic! I implemented the following functions:

- or (alias : ||)
- and (alias : &&)
- geq (alias : `>=`)
- gt (alias : `>`)
- leq (alias : `<=`)
- lt (alias :`<`)
- eq (alias : `==`)

Example:

![img.png](docs/assets/logic.png)
Binary file added docs/assets/logic.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/configuration/loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ pub fn load_color(string: String) -> Color {

pub fn replace_variable(str: String) -> String {
str.replace("%author%", "Charlotte Thomas")
.replace("%version%", "v2.3.1")
.replace("%version%", "v2.4.0")
.to_string()
}

Expand Down
Loading

0 comments on commit 44652a3

Please sign in to comment.