From 203f72d4d464e881d400573fae2ef9a29b893d26 Mon Sep 17 00:00:00 2001
From: itssuny <itssuny4@gmail.com>
Date: Wed, 20 Mar 2024 12:02:31 +0900
Subject: [PATCH 1/7] first cache program

---
 cachematrix.R | 30 +++++++++++++++++++++++++++++-
 1 file changed, 29 insertions(+), 1 deletion(-)

diff --git a/cachematrix.R b/cachematrix.R
index a50be65aa44..b65ce5f0735 100644
--- a/cachematrix.R
+++ b/cachematrix.R
@@ -3,8 +3,26 @@
 
 ## Write a short comment describing this function
 
-makeCacheMatrix <- function(x = matrix()) {
+##a <- c(2,1)
+##b <- c(5,3)
+##xyz <- rbind(a,b)
+##mm <- makeCacheMatrix(xyz)
+##cacheSolve(mm)
 
+makeCacheMatrix <- function(x = matrix()) {
+  inverseM <- NULL
+  set <- function(y) {
+    x <<- y
+    inverseM <<- NULL
+  }
+  get <- function() x
+  setinverse <- function(inverseMatrix) inverseM <<- inverseMatrix
+  getinverse <- function() inverseM
+  list(set = set, get = get,
+       setinverse = setinverse,
+       getinverse = getinverse)
+  
+  
 }
 
 
@@ -12,4 +30,14 @@ makeCacheMatrix <- function(x = matrix()) {
 
 cacheSolve <- function(x, ...) {
         ## Return a matrix that is the inverse of 'x'
+  
+  inverseM <- x$getinverse()
+  if(!is.null(inverseM)) {
+    message("getting cached data")
+    return(inverseM)
+  }
+  data <- x$get()
+  inverseM <- solve(data, ...)
+  x$setinverse(inverseM)
+  inverseM  
 }

From ae69efce251810ac9fc96192b55676770c00c2fc Mon Sep 17 00:00:00 2001
From: itssuny <itssuny4@gmail.com>
Date: Wed, 20 Mar 2024 14:19:29 +0900
Subject: [PATCH 2/7] second commit

---
 cachematrix.R | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/cachematrix.R b/cachematrix.R
index b65ce5f0735..fabb655a294 100644
--- a/cachematrix.R
+++ b/cachematrix.R
@@ -3,11 +3,6 @@
 
 ## Write a short comment describing this function
 
-##a <- c(2,1)
-##b <- c(5,3)
-##xyz <- rbind(a,b)
-##mm <- makeCacheMatrix(xyz)
-##cacheSolve(mm)
 
 makeCacheMatrix <- function(x = matrix()) {
   inverseM <- NULL
@@ -24,7 +19,7 @@ makeCacheMatrix <- function(x = matrix()) {
   
   
 }
-
+ 
 
 ## Write a short comment describing this function
 
@@ -41,3 +36,10 @@ cacheSolve <- function(x, ...) {
   x$setinverse(inverseM)
   inverseM  
 }
+
+##usage_________
+##a <- c(2,1)
+##b <- c(5,3)
+##xyz <- rbind(a,b)
+##mm <- makeCacheMatrix(xyz)
+##cacheSolve(mm)

From 839cea2cb944f3e80f42e0744f594d8f568a1b0b Mon Sep 17 00:00:00 2001
From: itssuny <itssuny4@gmail.com>
Date: Wed, 20 Mar 2024 14:22:18 +0900
Subject: [PATCH 3/7] third commit

---
 cachematrix.R | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/cachematrix.R b/cachematrix.R
index fabb655a294..f28269efa12 100644
--- a/cachematrix.R
+++ b/cachematrix.R
@@ -37,7 +37,7 @@ cacheSolve <- function(x, ...) {
   inverseM  
 }
 
-##usage_________
+##usage_________---------------
 ##a <- c(2,1)
 ##b <- c(5,3)
 ##xyz <- rbind(a,b)

From 1cd1d77015893a75daca3642f85e89e8610afa22 Mon Sep 17 00:00:00 2001
From: itssuny <itssuny4@gmail.com>
Date: Wed, 20 Mar 2024 14:53:35 +0900
Subject: [PATCH 4/7] third. add comment

---
 cachematrix.R | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/cachematrix.R b/cachematrix.R
index f28269efa12..a96c03ce966 100644
--- a/cachematrix.R
+++ b/cachematrix.R
@@ -37,7 +37,7 @@ cacheSolve <- function(x, ...) {
   inverseM  
 }
 
-##usage_________---------------
+##########usage________
 ##a <- c(2,1)
 ##b <- c(5,3)
 ##xyz <- rbind(a,b)

From e1b6abf25bd644d07a53b5bfca62a2084843de4f Mon Sep 17 00:00:00 2001
From: itssuny <itssuny4@gmail.com>
Date: Wed, 20 Mar 2024 14:56:32 +0900
Subject: [PATCH 5/7] fourth

---
 example.R | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)
 create mode 100644 example.R

diff --git a/example.R b/example.R
new file mode 100644
index 00000000000..16f5e0b29e3
--- /dev/null
+++ b/example.R
@@ -0,0 +1,26 @@
+makeVector <- function(x = numeric()) {
+  m <- NULL
+  set <- function(y) {
+    x <<- y
+    m <<- NULL
+  }
+  get <- function() x
+  setmean <- function(mean) m <<- mean
+  getmean <- function() m
+  list(set = set, get = get,
+       setmean = setmean,
+       getmean = getmean)
+}
+
+
+cachemean <- function(x, ...) {
+  m <- x$getmean()
+  if(!is.null(m)) {
+    message("getting cached data")
+    return(m)
+  }
+  data <- x$get()
+  m <- mean(data, ...)
+  x$setmean(m)
+  m
+}
\ No newline at end of file

From d1af1957385b66640d0a165e61fe27fdf71d1a18 Mon Sep 17 00:00:00 2001
From: itssuny <itssuny4@gmail.com>
Date: Wed, 20 Mar 2024 15:06:45 +0900
Subject: [PATCH 6/7] add comments

---
 cachematrix.R | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/cachematrix.R b/cachematrix.R
index a96c03ce966..4f817fa7f72 100644
--- a/cachematrix.R
+++ b/cachematrix.R
@@ -2,6 +2,7 @@
 ## functions do
 
 ## Write a short comment describing this function
+## this is for inverse matrix for caching..
 
 
 makeCacheMatrix <- function(x = matrix()) {
@@ -37,7 +38,7 @@ cacheSolve <- function(x, ...) {
   inverseM  
 }
 
-##########usage________
+###################usage________
 ##a <- c(2,1)
 ##b <- c(5,3)
 ##xyz <- rbind(a,b)

From 2c0f74715459ea750a331bac50fe5ab37e5aa397 Mon Sep 17 00:00:00 2001
From: itssuny <itssuny4@gmail.com>
Date: Wed, 20 Mar 2024 15:10:04 +0900
Subject: [PATCH 7/7] adding comment

---
 cachematrix.R | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/cachematrix.R b/cachematrix.R
index 4f817fa7f72..0efa96216db 100644
--- a/cachematrix.R
+++ b/cachematrix.R
@@ -23,7 +23,9 @@ makeCacheMatrix <- function(x = matrix()) {
  
 
 ## Write a short comment describing this function
-
+## cacheSolve function finds inverse matrix of x
+## if inverse matrix is already created, show message "getting cached data" and the inverse matrix. 
+## Otherwise show no message and the inverse matrix
 cacheSolve <- function(x, ...) {
         ## Return a matrix that is the inverse of 'x'
   
