Files
scl/README.md
2025-11-22 10:36:05 -05:00

60 lines
1.1 KiB
Markdown

# SCL: Simple CAS Language
*v1.0*
SCL aims to be a human-friendly Computer Algebra System (CAS) inspired by
[maxima](https://maxima.sourceforge.io/) that feels like writing on paper. In
its current state, SCL can be used as a functional programming language capable
of performing simple arithmetic. The codebase is about 2,400 lines of
handwritten C, including a parser, interpreter, and runtime. It uses a linked
environment scoping model.
## Usage
To download and run:
```bash
git clone https://git.signorovitch.org/scl/scl -b stable && cd scl
make release
./scl.out
```
## Syntax
SCL's syntax will feel familiar to other functional programming languages.
```scl
> x = 3 + 3 * 3; x + 1
= 13
> f(x) x + 1
> f(1)
= 2
> \x, y 2 * x + y $ (2, 3)
= 7
> f(g) g(2)
> f(\x 2 * x)
= 4
```
Here's a simple factorial function, using recursion:
```scl
> fac(n) = {
> f(n, a) = {
> if n == 1
> a
> else
> f(n - 1, a * n);
> }
>
> f(n, 1);
> }
```
SCL's syntax is quite flexible. The above function could be more concisely
written as:
```scl
> fac(n) (n, 1) -> f(n, a) ? n == 1 a f(n - 1, a * n)
```