initial commit

master
FelixBrendel 7 年前
当前提交
a7bb24cd6d
共有 2 个文件被更改,包括 111 次插入0 次删除
  1. +107
    -0
      Built-Ins.md
  2. +4
    -0
      Types.md

+ 107
- 0
Built-Ins.md

@@ -0,0 +1,107 @@
# Built-in functions

## Regular functions

| Symbol | Argument Count | Argument Types | Description | Accepted Keywords |
|-------------------|----------------|----------------|------------------------------------------------|-------------------|
| [`+`](#+) | any | `:number` | Adds up the arguments | |
| [`-`](#-) | any | `:number` | Subtracts the arguments from the first one | |
| [`*`](#*) | any | `:number` | Multiplies the arguments together | |
| [`/`](#/) | any | `:number` | Divides the arguments | |
| [`=`](#=) | any | overloaded | Checks if all the arguments are equivalent | |
| [`pair`](#pair) | 2 | any | Returns a pair of the two arguments | |
| [`first`](#first) | 1 | `:pair` | Returns the first element of the pair | |
| [`rest`](#rest) | 1 | `:pair` | Returns the rest of the pair | |
| [`eval`](#eval) | 1 | any | Evaluates the argument | |
| [`prog`](#prog) | any | any | Combines multiple expressions to one | |
| [`list`](#list) | any | any | Returns a list of the arguments | |
| [`print`](#print) | 1 | any | Prints the arguments | `:end` `:sep` |
| [`read`](#read) | 0 or 1 | any | Reads a string from stdin | |
| [`type`](#type) | 1 | any | Returns the type of the argument | |
| [`exit`](#exit) | 0 or 1 | `:number` | Exits the interpreter with the given exit code | |

## Special forms

| Symbol | Argument Count | Argument Types | Description |
|---------------------|----------------|----------------|-------------------------------------------------------------------------------------------------|
| [`and`](#and) | any | any | Logic and (with short circuiting) |
| [`or`](#or) | any | any | Logic or (with short circuiting) |
| [`not`](#not) | 1 | any | Logic not |
| [`if`](#if) | 2 or 3 | any | First arguments is the condition, second the "then" part, the optional thirt is the "else" part |
| [`quote`](#quote) | 1 | any | Returns the argument without evaluating it (as the syntax tree) |
| [`define`](#define) | 2 | `:symbol`, any | Defines a Symol in the the current environment |

## Reference

### `+`
Accepts any number of arguments of type `:number` and returns the sum
of them.

```lisp
(+ 1 2 3) ;; 1 + 2 + 3
> 6.00000
```

### `-`
Accepts any number of arguments of type `:number` and returns the
difference of the first number to the sum of the other arguments.

```lisp
(- 10) ;; watch out !
> 10.00000

(- 10 2 3 1) ;; 10 - 2 - 3 - 1 => 10 - (2 + 3 + 1)
> 4.00000
```

### `*`
Accepts any number of arguments of type `:number` and returns the
product of them.

```lisp
(* 3 4 2) ;; 3 * 4 * 2
> 6.00000
```

### `/`
Accepts any number of arguments of type `:number` and returns the
quotient of them.

```lisp
(/ 100)
> 100.00000

(/ 100 5 2) ;; ((100 / 5) / 2)
> 10.00000
```

### `=`
Accepts any number of arguments of any type and compares them,
returning 1.00000 if they are all equivalent (might still be different
objects) or `nil` if they are not all the same. The finction is
overloaded for all the built-in [types](types.md)

```lisp
(= 100)
> 100.00000

(/ 100 5 2) ;; ((100 / 5) / 2)
> 10.00000
```

### `pair`
### `first`
### `rest`
### `eval`
### `prog`
### `list`
### `print`
### `read`
### `type`
### `exit`
### `and`
### `or`
### `not`
### `if`
### `quote`
### `define`

+ 4
- 0
Types.md

@@ -0,0 +1,4 @@
# Built-in types

> asd
> dsa

正在加载...
取消
保存