You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -32,9 +32,9 @@ cargo install mech
32
32
33
33
## 📚 Documentation
34
34
35
-
New to Mech? Start with [Learn Mech in Fifteen Minutes](https://gitlab.com/mech-lang/docs/-/raw/v0.2-beta/III.guides/MechFifteen.mec).
35
+
New to Mech? Start with [Learn Mech in Fifteen Minutes](https://docs.mech-lang.org/III.guides/mech-in-fifteen-minutes.html).
36
36
37
-
Comprehensive documentation is available at [docs.mech-lang.org](https://docs.mech-lang.org) and open-sourced on [GitHub](https://github.com/mech-lang/docs).
37
+
Comprehensive documentation is available at [docs.mech-lang.org](https://docs.mech-lang.org) and open-sourced on [GitHub](https://github.com/mech-lang/mech/tree/main/docs).
Copy file name to clipboardExpand all lines: docs/I.getting-started/install.mec
+6-6Lines changed: 6 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -6,14 +6,14 @@ Download and Install Mech
6
6
7
7
The easiest way to install Mech is to use the installer provided for your platform. The installer includes the `mech` command-line tool, which is a standalone executable that includes everything you need to get started with Mech.
Right now, the installer is only available for Windows, but we are working on providing installers for other platforms in the future.
12
12
13
13
14
14
(1.1) Desktop App
15
15
16
-
We're experimenting with a Tauri-based app for Mech as well, which is kind of like Electron but Rust's version; it uses the system's webview to render the UI, which makes it much more lightweight and efficient. Right now all it does is wrap the Mech REPL, and it works, but it's not clear if this is the right direction for the project. If you want to try it out, you can [download the Mech Tauri app for Windows](https://github.com/mech-lang/mech/releases/download/v0.2.51-beta/mech-app_0.2.51_x86-64-setup.exe).
16
+
We're experimenting with a Tauri-based app for Mech as well, which is kind of like Electron but Rust's version; it uses the system's webview to render the UI, which makes it much more lightweight and efficient. Right now all it does is wrap the Mech REPL, and it works, but it's not clear if this is the right direction for the project. If you want to try it out, you can [download the Mech Tauri app for Windows](https://github.com/mech-lang/mech/releases/download/v0.2.52-beta/mech-app_0.2.52_x86-64-setup.exe).
17
17
18
18
19
19
2. Binary
@@ -25,10 +25,10 @@ Precompiled binaries are available for the following platforms:
Copy file name to clipboardExpand all lines: docs/II.reference/matrix.mec
+29-19Lines changed: 29 additions & 19 deletions
Original file line number
Diff line number
Diff line change
@@ -93,6 +93,33 @@ Row vectors and column vectors are special cases of matrices:
93
93
<[T]:_,1> -- A dynamic column vector with an unspecified number of elements
94
94
```
95
95
96
+
(2.1) Conversion
97
+
98
+
You can convert a matrix to another kind using a kind annotation. For example:
99
+
100
+
```mech:ex71
101
+
m := [1 2 3]
102
+
v<[u8]> := m -- Converts `[f64]` to `[u8]`
103
+
```
104
+
105
+
You can also convert a vector of numbers into a vector of strings:
106
+
107
+
```mech:ex72
108
+
v := [1 2 3]
109
+
s<[string]> := v -- Converts `[f64]` to `[string]`
110
+
```
111
+
112
+
(2.2) Reshape
113
+
114
+
You can reshape a matrix to a different size as long as the total number of elements remains the same. For example, you can reshape a 2x3 matrix into a 3x2 matrix:
115
+
116
+
```mech:ex81
117
+
m := [1 2 3 4 5 6]
118
+
v<[f64]:3,2> := m -- Reshapes the matrix to a 3x2 matrix
119
+
```
120
+
121
+
This will also convert the matrix elements to `u8` from `f64`.
Copy file name to clipboardExpand all lines: docs/II.reference/table.mec
+52-4Lines changed: 52 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -96,16 +96,36 @@ Tables can be constructed of vectors, matrices, or records.
96
96
97
97
(3.2) From a matrix
98
98
99
+
You can create a table from a matrix using a kind annotation, as long as the kinds of the table columns are compatible with the matrix kind. For example, if you have a matrix of kind `f64`, you can create a table with columns of kind `f64`:
100
+
101
+
For example:
102
+
103
+
```mech:ex3
104
+
x := [1 2; 3 4];
105
+
a<|foo<f64>,bar<f64>|> := x
106
+
```
107
+
This creates a table `a` with two columns, `foo` and `bar`, both of kind `f64`, and two rows corresponding to the rows of the matrix `x`.
108
+
109
+
The matrix `[a.foo a.bar]` is identical to the original matrix `x`.
110
+
111
+
It's possible to convert a matrix of one kind to a table of different kinded columns, as long as the conversion is valid. For example, you can convert a matrix of `f64` to a table with `u8` columns:
0 commit comments