Skip to content

Commit

Permalink
Merge branch 'master' of github.com:Flipez/monkey-lang
Browse files Browse the repository at this point in the history
  • Loading branch information
Flipez committed Sep 28, 2021
2 parents f7babd3 + 4d20bd7 commit 48d4760
Showing 1 changed file with 81 additions and 2 deletions.
83 changes: 81 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[![goreleaser](https://github.com/Flipez/rocket-lang/actions/workflows/release.yml/badge.svg)](https://github.com/Flipez/rocket-lang/actions/workflows/release.yml)

# General
# 🚀🇱🅰🆖

RocketLang as of version 0.9.5 is the _full_ (as in the book was worked through) version of [MonkeyLang](https://monkeylang.org/)
RocketLang as of version 0.9.5 is the _full_ (as in the book was worked through) version of [MonkeyLang](https://monkeylang.org/) and is then being extended with various useful and not so useful features.

## Installation

Expand All @@ -19,3 +19,82 @@ or download from [releases](https://github.com/Flipez/rocket-lang/releases).
* `rocket-lang FILE` will run the code in that file (no file extension check yet)
* Use _Javascript_ Highlighting in your editor for some convenience
* Checkout Code [Samples](examples/) for what is currently possible (and what not)

## Examples
### Variables
```js
let some_integer = 1;
let name = "RocketLang";
let array = [1, 2, 3, 4, 5];
let some_boolean = true;
```

Also expressions can be used
```js
let another_int = (10 / 2) * 5 + 30;
let an_array = [1 + 1, 2 * 2, 3];
```

### Functions
Implicit and explicit return statements are supported.
```js
let fibonacci = fn(x) {
if (x == 0) {
0
} else {
if (x == 1) {
return 1;
} else {
fibonacci(x - 1) + fibonacci(x - 2);
}
}
};
```
### Closures
```js
let newGreeter = fn(greeting) {
return fn(name) { puts(greeting + " " + name); }
};

let hello = newGreeter("Hello");

hello("dear, future Reader!");

```

### Data Types
#### Strings
```js
let a = "test_string;
let b = "test" + "_string";
let is_true = "test" == "test";
let is_false = "test" == "string";
```
#### Integer
```js
let a = 1;
let b = a + 2;
let is_true = 1 == 1;
let is_false = 1 == 2;
```
#### Boolean
```js
let a = true;
let b = false;
let is_true = a == a;
let is_false = a == b;
let is_true = a != b;
```
#### Hashes
```js
let people = [{"name": "Anna", "age": 24}, {"name": "Bob", "age": 99}];
```

0 comments on commit 48d4760

Please sign in to comment.