Skip to content

Commit

Permalink
[Doc] add array bonus documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
nydragon committed Mar 10, 2023
1 parent e399b98 commit e631e35
Show file tree
Hide file tree
Showing 3 changed files with 134 additions and 9 deletions.
9 changes: 0 additions & 9 deletions doc/bonuses.md

This file was deleted.

Binary file added doc/bonuses.pdf
Binary file not shown.
134 changes: 134 additions & 0 deletions doc/bonuses_documentation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@

# Bonuses

- [REPL](#repl)
- [Rigor](#rigor)
- [Syntax Documentation for compiled code](#syntax-documentation-for-compiled-code)
- [Strings, string operations and character escaping](#strings-string-operations-and-character-escaping)
- [Arrays](#arrays)
- [Array Nesting](#array-nesting)
- [Array Operation](#array-operation)
- [Head](#head)
- [Last](#last)
- [Tail](#tail)
- [Init](#init)
- [Join](#join)
- [PushFront](#pushfront)
- [Pushback](#pushback)
- [Input/Output](#inputoutput)
- [Reading from Stdin](#reading-from-stdin)
- [Writing to Stdout](#writing-to-stdout)
- [Reading files](#reading-files)
- [Floating point numbers](#floating-point-numbers)


## REPL

## Rigor

### Syntax Documentation for compiled code
## Strings, string operations and character escaping

## Arrays

We implemented syntactic sugar for LISP style lists so that they may be written using a more familiar style

`(1 2 3 4 5)` -> `[1, 2, 3, 4, 5]`

We chose syntactic sugar over native handling as it will result in less written code in project overall.

Arrays can contain any amount of Atomic values.

### Array Nesting

Arrays can have an infinite amount of nesting, to represent 2d arrays, 3d arrays and so on.

`[[1,2,3,4,5],[1,2,3,4,5]]`

### Array Operation

There are a total of 7 array operations:

#### Head

`head` returns the first element of an array.

```lisp
> (define a [1, 2, 3])
> (head a)
1
```

#### Last

`last` returns the first element of an array.

```lisp
> (define a [1, 2, 3])
> (last a)
3
```

#### Tail

`tail` returns the array with its first element removed.

```lisp
> (define a [1, 2, 3])
> (tail a)
[2,3]
```

#### Init

`init` returns the array with its last element removed.

```lisp
> (define a [1, 2, 3])
> (init a)
[1,2]
```

#### Join

`join` concatenates 2 arrays and returns it.

```lisp
> (define a [1, 2, 3])
> (define b [4, 5, 6])
> (join a b)
[1,2,3,4,5,6]
```

#### PushFront

`pushFront` adds an element to the beginning of an array and returns the array.

```lisp
> (define a [2, 3, 4])
> (define b 1)
> (pushFront a b)
[1,2,3,4]
```

#### Pushback

`pushBack` adds an element to the end of an array and returns the array.

```lisp
> (define a [1, 2, 3])
> (define b 4)
> (pushBack a b)
[1,2,3,4]
```


## Input/Output

### Reading from Stdin

### Writing to Stdout
### Reading files

## Floating point numbers

0 comments on commit e631e35

Please sign in to comment.