You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
nprimo 6c11610c4f docs(matrix_multiplication): update subject 2 years ago
..
README.md docs(matrix_multiplication): update subject 2 years ago

README.md

matrix_multiplication

Instructions

  • Define a struct named Matrix as a tuple of two tuples. The nested tuple will contain two i32.

  • Create a function named multiply that receives a Matrix and an i32 and returns the Matrix with each number multiplied by the second argument.

pub fn multiply(m: Matrix, multiplier: i32) -> Matrix {
}

Matrix must implement Debug, PartialEq and Eq. You can use derive.

Remember that you are defining a library, so any element that can be called from an external crate must be made public.

Usage

Here is a possible program to test your function

use matrix_multiplication::*;

fn main() {
    let matrix = Matrix((1, 3), (4, 5));
    println!("Original matrix {:?}", matrix);
    println!("Matrix after multiply {:?}", multiply(matrix, 3));
}

And its output:

$ cargo run
Original matrix Matrix ((1, 3), (4, 5))
Matrix after multiply ((3, 9), (12, 15))
$

Notions