scl/README.md

54 lines
880 B
Markdown
Raw Normal View History

2024-12-14 20:35:36 -05:00
# SCL: Simple CAS Language
2024-12-21 11:10:01 -05:00
## Current State
The following things are possible:
1. Floating-point numbers
2. Negative numbers
3. Addition
4. Subtraction
5. Multiplication
## Syntax (Planned)
2024-11-07 19:55:54 -05:00
As one would expect, you can evaluate simple infix expressions:
```scl
> 1 + 1
= 2
```
You can also define your own functions:
```scl
2024-12-14 20:35:36 -05:00
> f(x) = 2x
2024-11-07 19:55:54 -05:00
> f(2)
= 4
```
2024-12-14 20:35:36 -05:00
Symbolic algebra is done in the following manner:
```scl
2024-12-21 11:10:01 -05:00
> f(x) = x^4
2024-12-14 20:35:36 -05:00
> diff(f, x:sym, 2)
2024-12-21 11:10:01 -05:00
= 12x^2
2024-12-14 20:35:36 -05:00
```
2024-11-07 19:55:54 -05:00
SCL will dynamically decide on types, but you can state them explicitly as
well:
```scl
2024-12-14 20:35:36 -05:00
> f(x:int) = 2x
2024-11-07 19:55:54 -05:00
> f(2.2)
! f(x:int): x must be of type int.
```
Variables can be defined, with several attributes:
```scl
> a = 1 // Interpret type automatically.
> b:int = 1 // Must be int.
> c:const:int = 1 // Constant: value can never change.
2024-12-14 20:35:36 -05:00
> x:sym // Treated symbolicaly.
2024-11-07 19:55:54 -05:00
```