|
1 |
| -## Put comments here that give an overall description of what your |
2 |
| -## functions do |
| 1 | +# Hi! I'm the guy from Ruby Planet! And I love clear code. |
| 2 | +# It was painfull for me to read initial version, so I've refactored all names. |
| 3 | +# Please Enjoy R and this MOOC. If you are interested in detailed information |
| 4 | +# please read detailed comment at the end of code. |
| 5 | +# Thanks for your review! |
3 | 6 |
|
4 |
| -## Write a short comment describing this function |
| 7 | +makeCacheMatrix <- function(local_matrix = matrix()) { |
| 8 | + # By default local_matrix is the empty matrix |
5 | 9 |
|
6 |
| -makeCacheMatrix <- function(x = matrix()) { |
| 10 | + # Initializing variable supposed for cached solution |
| 11 | + cached_solution <- NULL |
7 | 12 |
|
8 |
| -} |
| 13 | + set_matrix <- function(arg) { |
| 14 | + local_matrix <<- arg |
| 15 | + cached_solution <<- NULL |
| 16 | + } |
| 17 | + get_matrix <- function() local_matrix |
| 18 | + |
| 19 | + # Setting cached solution |
| 20 | + set_solved <- function(solution) cached_solution <<- solution |
| 21 | + # Getting cached solution |
| 22 | + get_solved <- function() cached_solution |
9 | 23 |
|
| 24 | + # Return list of functions list of functions: |
| 25 | + # - `set_matrix` - set the value of the matrix |
| 26 | + # - `get_matrix` - get the value of the matrix |
| 27 | + # - `set_solved` - set the value of the inverted matrix |
| 28 | + # - `get_solved` - get the value of the inverted matrix |
| 29 | + |
| 30 | + list( |
| 31 | + set_matrix = set_matrix, # ...$set_matrix |
| 32 | + get_matrix = get_matrix, # ...$get_matrix |
| 33 | + set_solved = set_solved, |
| 34 | + get_solved = get_solved) |
| 35 | +} |
10 | 36 |
|
11 | 37 | ## Write a short comment describing this function
|
12 | 38 |
|
|
0 commit comments