From d8e7ca7bc5f29ddcd015d3d89679dfb326aa7db2 Mon Sep 17 00:00:00 2001 From: davhojt Date: Sun, 22 May 2022 10:47:58 +0300 Subject: [PATCH] docs(matrix_transposition): correct grammar --- subjects/matrix_transposition/README.md | 54 +++++++++++-------------- 1 file changed, 24 insertions(+), 30 deletions(-) diff --git a/subjects/matrix_transposition/README.md b/subjects/matrix_transposition/README.md index eddbc2af..0be750d0 100644 --- a/subjects/matrix_transposition/README.md +++ b/subjects/matrix_transposition/README.md @@ -2,49 +2,29 @@ ### Instructions -- Define the structure matrix as a tuple of 2 tuples of 2 `i32`'s. +- Define a `struct` named `Matrix` as a tuple of 2 tuples. The nested tuple will contain 2 `i32`s. -- Define a **function** that calculates the transpose matrix of a 2x2 matrix. +- Create a **function** named `transpose` that calculates the transposition of a 2x2 matrix. -- Note: - - - The transpose of a matrix `A` is the matrix `A'` where `A'`'s columns are `A`'s row and the rows are the columns: +```rust +pub fn transpose(m: Matrix) -> Matrix { +} +``` -Example: +The transposition of a matrix, switches the columns to rows, and the rows to columns. For example: ``` ( a b ) __ transposition __> ( a c ) ( c d ) ( b d ) ``` -- Matrix must implement Debug, PartialEq and Eq. You can use derive. - -- Remember that you are defining a library so you have to make public the elements that are going to be called from an external crate. - -### Notions - -- [Defining a struct](https://doc.rust-lang.org/stable/book/ch05-01-defining-structs.html) - -- [The Tuple Type](https://doc.rust-lang.org/stable/book/ch03-02-data-types.html?highlight=accessing%20a%20tuple#compound-types) - -- [Tuples](https://doc.rust-lang.org/rust-by-example/primitives/tuples.html) - -- [Tuple Structs without Named Fields](https://doc.rust-lang.org/stable/book/ch05-01-defining-structs.html?highlight=tuple#using-tuple-structs-without-named-fields-to-create-different-types) - -- [Adding Useful Functionality with Derived Traits](https://doc.rust-lang.org/stable/book/ch05-02-example-structs.html?highlight=debug%20deriv#adding-useful-functionality-with-derived-traits) - -- [Chapter 7](https://doc.rust-lang.org/stable/book/ch07-03-paths-for-referring-to-an-item-in-the-module-tree.html) +`Matrix` must implement `Debug`, `PartialEq` and `Eq`. You can use `derive`. -### Expected Function - -```rust -pub fn transpose(m: Matrix) -> Matrix { -} -``` +> Remember that you are defining a library, so you must make the elements that can be called from an external crate public. ### Usage -Here is a posible program to test your function +Here is a possible program to test your function ```rust use matrix_transposition::transpose; @@ -65,3 +45,17 @@ Original matrix Matrix((1, 3), (4, 5)) Transpose matrix Matrix((1, 4), (3, 5)) $ ``` + +### Notions + +- [Defining a struct](https://doc.rust-lang.org/stable/book/ch05-01-defining-structs.html) + +- [The Tuple Type](https://doc.rust-lang.org/stable/book/ch03-02-data-types.html?highlight=accessing%20a%20tuple#compound-types) + +- [Tuples](https://doc.rust-lang.org/rust-by-example/primitives/tuples.html) + +- [Tuple Structs without Named Fields](https://doc.rust-lang.org/stable/book/ch05-01-defining-structs.html?highlight=tuple#using-tuple-structs-without-named-fields-to-create-different-types) + +- [Adding Useful Functionality with Derived Traits](https://doc.rust-lang.org/stable/book/ch05-02-example-structs.html?highlight=debug%20deriv#adding-useful-functionality-with-derived-traits) + +- [Chapter 7](https://doc.rust-lang.org/stable/book/ch07-03-paths-for-referring-to-an-item-in-the-module-tree.html)