67 lines
1.2 KiB
Markdown
67 lines
1.2 KiB
Markdown
---
|
|
title: "Syntax"
|
|
weight: 1
|
|
---
|
|
|
|
# Rays
|
|
|
|
Either a variable (uppercase, possibly followed by digits) or a polarised (+/-)
|
|
or unpolarised (lowercase, possibly containing `_` and digits)
|
|
function symbol applied to other rays (or nothing in case of constants):
|
|
|
|
`X`, `a`, `f(X)`, `+f(X)`, `-f(-h(a, Y1), X2)`, `+add_dec(0, 2, 2)`.
|
|
|
|
Commas can be omitted:
|
|
|
|
`-f(-h(a Y1) X2)`, `+add_dec(0 2 2)`, `string(hello i am X)`.
|
|
|
|
# Cons
|
|
|
|
There is a special binary infix function symbol `:` which can be used to
|
|
concatenate rays:
|
|
|
|
`a:X`, `a:b:b:X`, `f(a:X):+f(0:1:X):-f(Y)`.
|
|
|
|
# Stars
|
|
|
|
An unordered sequence of rays ending with a semicolon `;`:
|
|
|
|
```
|
|
X a +f(X);
|
|
```
|
|
|
|
# Constellations
|
|
|
|
An unordered sequence of stars:
|
|
|
|
```
|
|
X a +f(X); -f(-h(a Y1) X2);
|
|
+add_dec(0 2 2);
|
|
```
|
|
|
|
All variables are local to their stars, hence the occurrences of `X` in the
|
|
first line are distinct from the one in the second line.
|
|
|
|
# Focus
|
|
|
|
You can prefix stars with a `@` symbol to put a *focus* over them. This will
|
|
affect the behaviour of computation:
|
|
|
|
```
|
|
@X a +f(X);
|
|
@-f(-h(a Y1) X2);
|
|
+add_dec(0 2 2);
|
|
```
|
|
|
|
# Comments
|
|
|
|
```
|
|
'this is a comment on a single line
|
|
'this is another comment
|
|
|
|
'''
|
|
this is a
|
|
comment on
|
|
several lines
|
|
'''
|
|
``` |