all repos — mn @ ce099d5b026d7b1011ce14cfc6be793ffc8a2449

A truly minimal concatenative programming language.

docs/get-started.md

 1
 2
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
---

content-type: "page"
title: "Get Started"

---

{@ _defs_.md || 0 @}

You can download one of the following pre-built mn binaries:

-   {#release||{{$version}}||macosx||macOS||x64#}
-   {#release||{{$version}}||windows||Windows||x64#}
-   {#release||{{$version}}||linux||Linux||x64#}

{#release -> [mn v$1 for $3 ($4)](https://github.com/h3rald/mn/releases/download/v$1/mn_v$1_$2_$4.zip) #}

## Building from source

Alternatively, you can build mn from source as follows:

1. Download and install [nim](https://nim-lang.org).
3. Clone the mn [repository](https://github.com/h3rald/mn).
4. Navigate to the mn repository local folder.
6. Run **./build.sh**.

## Running the mn REPL

To start the mn REPL, run [mn](class:cmd) with no arguments. You will be presented with a prompt displaying the path to the current directory:

> %mn-terminal%
> mn v$version
> [::](class:prompt)

You can type mn code and press [ENTER](class:kbd) to evaluate it immediately:

> %mn-terminal%
> [::](class:prompt) 2 2 +
> 4
> [::](class:prompt)

The result of each operation will be placed on top of the stack, and it will be available to subsequent operation

> %mn-terminal%
> [::](class:prompt) dup \*
> 16
> [::](class:prompt)

To exit mn shell, press [CTRL+C](class:kbd) or type [0 exit](class:cmd) and press [ENTER](class:kbd).

## Executing a mn Program

To execute a mn script, you can:

-   Run `mn -e:"... program ..."` to execute a program inline.
-   Run `mn myfile.mn` to execute a program contained in a file.

mn also supports running programs from standard input, so the following command can also be used (on Unix-like system) to run a program saved in [myfile.mn](class:file):

> %mn-terminal%
>
> [$](class:prompt) cat myfile.mn | mn