|
1 | | -# Rock |
2 | | - |
3 | | -⚠️The project is at a very early stage, lots of things will not work. |
4 | | - |
5 | | -[](https://GitHub.com/jarkonik/rocklang/releases/) |
6 | | -[](https://www.paypal.com/donate?hosted_button_id=Y25KDXY4LJYQ2) |
7 | | -[](https://github.com/jarkonik/rocklang/actions/workflows/main.yml) |
8 | | -[](https://codecov.io/gh/jarkonik/rocklang) |
9 | | -[](https://discord.gg/NK3baHRTve) |
11 | | -[](https://opensource.org/licenses/MIT) |
12 | | - |
13 | | -<img src="./rock.svg" width="100" height="100"> |
14 | | - |
15 | | -JIT-compiled functional programming language. |
16 | | - |
17 | | -## Getting started |
18 | | - |
19 | | -### Windows |
20 | | - |
21 | | -1. [Download and run the installer.](https://github.com/jarkonik/rocklang/releases/latest/download/rocklang-windows-latest.msi) |
22 | | -2. At this point, if you haven't changed the default installer options, |
23 | | - `rocklang.exe` should be installed and added to your `PATH`. |
24 | | -3. Create a file named `main.rc` in a directory of your choice, with following |
25 | | - content: |
26 | | -``` |
27 | | -print("Hello from rocklang") |
28 | | -``` |
29 | | -4. While being in the same directory, that you've created the source file in, run `rocklang main.rc` from PowerShell or |
30 | | - Command Prompt. |
31 | | -5. You should see text `Hello from rocklang` printed in your terminal. |
32 | | - |
33 | | -## Example |
34 | | - |
35 | | -Sample implementation of Sieve of Eratosthenes written in Rock |
36 | | - |
37 | | -```c |
38 | | -memset = (vec: vec, val: number, n: number): vec => { |
39 | | - i = 0 |
40 | | - while i < n { |
41 | | - vec = vecset(vec, i, val) |
42 | | - i = i + 1 |
43 | | - } |
44 | | - vec |
45 | | -} |
46 | | - |
47 | | -sieve = (n: number): void => { |
48 | | - v = vecnew() |
49 | | - prime = memset(v, 1, n + 1) |
50 | | - |
51 | | - p = 2 |
52 | | - |
53 | | - while p * p <= n { |
54 | | - if vecget(prime, p) == 1 { |
55 | | - i = p * p |
56 | | - while i <= n { |
57 | | - prime = vecset(prime, i, 0) |
58 | | - i = i + p |
59 | | - } |
60 | | - } |
61 | | - |
62 | | - p = p + 1 |
63 | | - } |
64 | | - |
65 | | - p = 2 |
66 | | - |
67 | | - while p <= n { |
68 | | - if vecget(prime, p) == 1 { |
69 | | - print(string(p)) |
70 | | - print("\n") |
71 | | - } |
72 | | - |
73 | | - p = p + 1 |
74 | | - } |
75 | | -} |
76 | | - |
77 | | -sieve(100) |
78 | | -``` |
79 | | -
|
80 | | -## Building from source |
81 | | -1. Install Rust compiler that supports Rust Edition 2021, along with `cargo` tool, in your favorite fashion. |
82 | | -2. Install llvm 13 |
83 | | -3. Run `cargo build` to build binaries or `cargo run examples/sieve.rc` to run a sample program. |
84 | | -
|
85 | | -## License |
86 | | -
|
87 | | -This project is licensed under the terms of the MIT license. |
| 1 | +# Rock |
| 2 | + |
| 3 | +⚠️The project is at a very early stage, lots of things will not work. |
| 4 | + |
| 5 | +[](https://GitHub.com/jarkonik/rocklang/releases/) |
| 6 | +[](https://www.paypal.com/donate?hosted_button_id=Y25KDXY4LJYQ2) |
| 7 | +[](https://github.com/jarkonik/rocklang/actions/workflows/main.yml) |
| 8 | +[](https://codecov.io/gh/jarkonik/rocklang) |
| 9 | +[](https://discord.gg/NK3baHRTve) |
| 11 | +[](https://opensource.org/licenses/MIT) |
| 12 | + |
| 13 | +<img src="./rock.svg" width="100" height="100"> |
| 14 | + |
| 15 | +JIT-compiled functional programming language. |
| 16 | + |
| 17 | +## Getting started |
| 18 | + |
| 19 | +### Windows |
| 20 | + |
| 21 | +1. [Download and run the installer.](https://github.com/jarkonik/rocklang/releases/latest/download/rocklang-windows-latest.msi) |
| 22 | +2. At this point, if you haven't changed the default installer options, |
| 23 | + `rocklang.exe` should be installed and added to your `PATH`. |
| 24 | +3. Create a file named `main.rc` in a directory of your choice, with following |
| 25 | + content: |
| 26 | +``` |
| 27 | +print("Hello from rocklang") |
| 28 | +``` |
| 29 | +4. While being in the same directory, that you've created the source file in, run `rocklang main.rc` from PowerShell or |
| 30 | + Command Prompt. |
| 31 | +5. You should see text `Hello from rocklang` printed in your terminal. |
| 32 | + |
| 33 | +## Example |
| 34 | + |
| 35 | +Sample implementation of Sieve of Eratosthenes written in Rock |
| 36 | + |
| 37 | +```c |
| 38 | +memset = (vec: vec, val: number, n: number): vec => { |
| 39 | + i = 0 |
| 40 | + while i < n { |
| 41 | + vec = vecset(vec, i, val) |
| 42 | + i = i + 1 |
| 43 | + } |
| 44 | + vec |
| 45 | +} |
| 46 | + |
| 47 | +sieve = (n: number): void => { |
| 48 | + v = vecnew() |
| 49 | + prime = memset(v, 1, n + 1) |
| 50 | + |
| 51 | + p = 2 |
| 52 | + |
| 53 | + while p * p <= n { |
| 54 | + if vecget(prime, p) == 1 { |
| 55 | + i = p * p |
| 56 | + while i <= n { |
| 57 | + prime = vecset(prime, i, 0) |
| 58 | + i = i + p |
| 59 | + } |
| 60 | + } |
| 61 | + |
| 62 | + p = p + 1 |
| 63 | + } |
| 64 | + |
| 65 | + p = 2 |
| 66 | + |
| 67 | + while p <= n { |
| 68 | + if vecget(prime, p) == 1 { |
| 69 | + print(string(p)) |
| 70 | + print("\n") |
| 71 | + } |
| 72 | + |
| 73 | + p = p + 1 |
| 74 | + } |
| 75 | +} |
| 76 | + |
| 77 | +sieve(100) |
| 78 | +``` |
| 79 | +
|
| 80 | +## Building from source |
| 81 | +1. Install Rust compiler that supports Rust Edition 2021, along with `cargo` tool, in your favorite fashion. |
| 82 | +2. Install llvm 13 |
| 83 | +3. Run `cargo build` to build binaries or `cargo run examples/sieve.rc` to run a sample program. |
| 84 | +
|
| 85 | +## License |
| 86 | +
|
| 87 | +This project is licensed under the terms of the MIT license. |
0 commit comments