scl/README.md

45 lines
713 B
Markdown
Raw Normal View History

2024-12-14 20:35:36 -05:00
# SCL: Simple CAS Language
2024-11-07 19:55:54 -05:00
## Syntax
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
> f(x) = e^x
> diff(f, x:sym, 2)
= e^x
```
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
```