Skip to content

Commit

Permalink
Updates
Browse files Browse the repository at this point in the history
  • Loading branch information
nishantpainter committed Jun 25, 2023
1 parent a9d851d commit bc25b1f
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 36 deletions.
2 changes: 1 addition & 1 deletion 404.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<!DOCTYPE html><html><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width"/><title>404: This page could not be found</title><meta name="next-head-count" content="3"/><noscript data-n-css=""></noscript><script defer="" nomodule="" src="/_next/static/chunks/polyfills-c67a75d1b6f99dc8.js"></script><script src="/_next/static/chunks/webpack-0ccd4dfd07ca212e.js" defer=""></script><script src="/_next/static/chunks/main-27ec7e2cb41f7601.js" defer=""></script><script src="/_next/static/chunks/pages/_app-169dc90af0efbdab.js" defer=""></script><script src="/_next/static/chunks/pages/_error-8283a45682809e39.js" defer=""></script><script src="/_next/static/o3_1_agkA_4wd4L16CVFC/_buildManifest.js" defer=""></script><script src="/_next/static/o3_1_agkA_4wd4L16CVFC/_ssgManifest.js" defer=""></script></head><body><div id="__next"><div style="font-family:system-ui,&quot;Segoe UI&quot;,Roboto,Helvetica,Arial,sans-serif,&quot;Apple Color Emoji&quot;,&quot;Segoe UI Emoji&quot;;height:100vh;text-align:center;display:flex;flex-direction:column;align-items:center;justify-content:center"><div><style>body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}</style><h1 class="next-error-h1" style="display:inline-block;margin:0 20px 0 0;padding-right:23px;font-size:24px;font-weight:500;vertical-align:top;line-height:49px">404</h1><div style="display:inline-block;text-align:left"><h2 style="font-size:14px;font-weight:400;line-height:49px;margin:0">This page could not be found<!-- -->.</h2></div></div></div></div><script id="__NEXT_DATA__" type="application/json">{"props":{"pageProps":{"statusCode":404}},"page":"/_error","query":{},"buildId":"o3_1_agkA_4wd4L16CVFC","nextExport":true,"isFallback":false,"gip":true,"scriptLoader":[]}</script></body></html>
<!DOCTYPE html><html><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width"/><title>404: This page could not be found</title><meta name="next-head-count" content="3"/><noscript data-n-css=""></noscript><script defer="" nomodule="" src="/_next/static/chunks/polyfills-c67a75d1b6f99dc8.js"></script><script src="/_next/static/chunks/webpack-0ccd4dfd07ca212e.js" defer=""></script><script src="/_next/static/chunks/main-27ec7e2cb41f7601.js" defer=""></script><script src="/_next/static/chunks/pages/_app-169dc90af0efbdab.js" defer=""></script><script src="/_next/static/chunks/pages/_error-8283a45682809e39.js" defer=""></script><script src="/_next/static/0n5_zcz2RTFdycq49C9tJ/_buildManifest.js" defer=""></script><script src="/_next/static/0n5_zcz2RTFdycq49C9tJ/_ssgManifest.js" defer=""></script></head><body><div id="__next"><div style="font-family:system-ui,&quot;Segoe UI&quot;,Roboto,Helvetica,Arial,sans-serif,&quot;Apple Color Emoji&quot;,&quot;Segoe UI Emoji&quot;;height:100vh;text-align:center;display:flex;flex-direction:column;align-items:center;justify-content:center"><div><style>body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}</style><h1 class="next-error-h1" style="display:inline-block;margin:0 20px 0 0;padding-right:23px;font-size:24px;font-weight:500;vertical-align:top;line-height:49px">404</h1><div style="display:inline-block;text-align:left"><h2 style="font-size:14px;font-weight:400;line-height:49px;margin:0">This page could not be found<!-- -->.</h2></div></div></div></div><script id="__NEXT_DATA__" type="application/json">{"props":{"pageProps":{"statusCode":404}},"page":"/_error","query":{},"buildId":"0n5_zcz2RTFdycq49C9tJ","nextExport":true,"isFallback":false,"gip":true,"scriptLoader":[]}</script></body></html>
2 changes: 1 addition & 1 deletion 404/index.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<!DOCTYPE html><html><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width"/><title>404: This page could not be found</title><meta name="next-head-count" content="3"/><noscript data-n-css=""></noscript><script defer="" nomodule="" src="/_next/static/chunks/polyfills-c67a75d1b6f99dc8.js"></script><script src="/_next/static/chunks/webpack-0ccd4dfd07ca212e.js" defer=""></script><script src="/_next/static/chunks/main-27ec7e2cb41f7601.js" defer=""></script><script src="/_next/static/chunks/pages/_app-169dc90af0efbdab.js" defer=""></script><script src="/_next/static/chunks/pages/_error-8283a45682809e39.js" defer=""></script><script src="/_next/static/o3_1_agkA_4wd4L16CVFC/_buildManifest.js" defer=""></script><script src="/_next/static/o3_1_agkA_4wd4L16CVFC/_ssgManifest.js" defer=""></script></head><body><div id="__next"><div style="font-family:system-ui,&quot;Segoe UI&quot;,Roboto,Helvetica,Arial,sans-serif,&quot;Apple Color Emoji&quot;,&quot;Segoe UI Emoji&quot;;height:100vh;text-align:center;display:flex;flex-direction:column;align-items:center;justify-content:center"><div><style>body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}</style><h1 class="next-error-h1" style="display:inline-block;margin:0 20px 0 0;padding-right:23px;font-size:24px;font-weight:500;vertical-align:top;line-height:49px">404</h1><div style="display:inline-block;text-align:left"><h2 style="font-size:14px;font-weight:400;line-height:49px;margin:0">This page could not be found<!-- -->.</h2></div></div></div></div><script id="__NEXT_DATA__" type="application/json">{"props":{"pageProps":{"statusCode":404}},"page":"/_error","query":{},"buildId":"o3_1_agkA_4wd4L16CVFC","nextExport":true,"isFallback":false,"gip":true,"scriptLoader":[]}</script></body></html>
<!DOCTYPE html><html><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width"/><title>404: This page could not be found</title><meta name="next-head-count" content="3"/><noscript data-n-css=""></noscript><script defer="" nomodule="" src="/_next/static/chunks/polyfills-c67a75d1b6f99dc8.js"></script><script src="/_next/static/chunks/webpack-0ccd4dfd07ca212e.js" defer=""></script><script src="/_next/static/chunks/main-27ec7e2cb41f7601.js" defer=""></script><script src="/_next/static/chunks/pages/_app-169dc90af0efbdab.js" defer=""></script><script src="/_next/static/chunks/pages/_error-8283a45682809e39.js" defer=""></script><script src="/_next/static/0n5_zcz2RTFdycq49C9tJ/_buildManifest.js" defer=""></script><script src="/_next/static/0n5_zcz2RTFdycq49C9tJ/_ssgManifest.js" defer=""></script></head><body><div id="__next"><div style="font-family:system-ui,&quot;Segoe UI&quot;,Roboto,Helvetica,Arial,sans-serif,&quot;Apple Color Emoji&quot;,&quot;Segoe UI Emoji&quot;;height:100vh;text-align:center;display:flex;flex-direction:column;align-items:center;justify-content:center"><div><style>body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}</style><h1 class="next-error-h1" style="display:inline-block;margin:0 20px 0 0;padding-right:23px;font-size:24px;font-weight:500;vertical-align:top;line-height:49px">404</h1><div style="display:inline-block;text-align:left"><h2 style="font-size:14px;font-weight:400;line-height:49px;margin:0">This page could not be found<!-- -->.</h2></div></div></div></div><script id="__NEXT_DATA__" type="application/json">{"props":{"pageProps":{"statusCode":404}},"page":"/_error","query":{},"buildId":"0n5_zcz2RTFdycq49C9tJ","nextExport":true,"isFallback":false,"gip":true,"scriptLoader":[]}</script></body></html>
4 changes: 2 additions & 2 deletions blogs/functional-programming-memoization/index.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion blogs/functional-programming-memoization/index.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ c:I{"id":"1978","chunks":["519:static/chunks/519-a3b077c6f8d3e235.js","49:static
3:[["$","html",null,{"lang":"en","children":[["$","$L6",null,{"async":true,"src":"https://www.googletagmanager.com/gtag/js?id=UA-171631214-1"}],["$","$L6",null,{"id":"google-analytics","strategy":"afterInteractive","children":"window.dataLayer = window.dataLayer || [];\n function gtag() {\n dataLayer.push(arguments);\n }\n gtag(\"js\", new Date());\n \n gtag(\"config\", \"UA-171631214-1\");\n "}],["$","$L6",null,{"data-ad-client":"ca-pub-4302795410966209","async":true,"src":"https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"}],["$","body",null,{"children":["$","$L7",null,{"children":[["$","$L8",null,{}],["$","$L9",null,{"parallelRouterKey":"children","segmentPath":["children"],"error":"$undefined","errorStyles":"$undefined","loading":"$undefined","loadingStyles":"$undefined","hasLoading":false,"template":["$","$La",null,{}],"templateStyles":"$undefined","notFound":"$undefined","notFoundStyles":"$undefined","asNotFound":"$undefined","childProp":{"current":["$","$L9",null,{"parallelRouterKey":"children","segmentPath":["children","blogs","children"],"error":"$undefined","errorStyles":"$undefined","loading":"$undefined","loadingStyles":"$undefined","hasLoading":false,"template":["$","$La",null,{}],"templateStyles":"$undefined","notFound":"$undefined","notFoundStyles":"$undefined","asNotFound":"$undefined","childProp":{"current":["$","$L9",null,{"parallelRouterKey":"children","segmentPath":["children","blogs","children",["slug","functional-programming-memoization","d"],"children"],"error":"$undefined","errorStyles":"$undefined","loading":"$undefined","loadingStyles":"$undefined","hasLoading":false,"template":["$","$La",null,{}],"templateStyles":"$undefined","notFound":"$undefined","notFoundStyles":"$undefined","asNotFound":"$undefined","childProp":{"current":["$Lb",null],"segment":"__PAGE__?{\"slug\":\"functional-programming-memoization\"}"},"styles":[["$","link","0",{"rel":"stylesheet","href":"/_next/static/css/2fd3c970a312a5ab.css","precedence":"next"}]]}],"segment":["slug","functional-programming-memoization","d"]},"styles":[]}],"segment":"blogs"},"styles":[]}],["$","$Lc",null,{}]]}]}]]}],null]
4:[[["$","meta",null,{"charSet":"utf-8"}],["$","title",null,{"children":"Functional Programming - Memoization"}],["$","meta",null,{"name":"description","content":"Memoization is a technique used to store the result of the expensive function call in a cache and return them when the same input is used again rather than a fresh computation."}],null,[[["$","link",null,{"rel":"author","href":"https://github.com/nishantpainter"}],["$","meta",null,{"name":"author","content":"Nishant Painter"}]]],null,null,null,null,null,null,["$","meta",null,{"name":"viewport","content":"width=device-width, initial-scale=1"}],null,null,null,null,null,null,null,null,["$","meta",null,{"name":"category","content":"technology"}],null,[]],[null,null,null,null],null,null,[null,null,null,null,null],null,[null,["$","meta",null,{"property":"og:title","content":"Functional Programming - Memoization"}],["$","meta",null,{"property":"og:description","content":"Memoization is a technique used to store the result of the expensive function call in a cache and return them when the same input is used again rather than a fresh computation."}],["$","meta",null,{"property":"og:url","content":"https://nishantpainter.com//blogs/functional-programming-memoization"}],null,null,null,null,[[["$","meta",null,{"property":"og:image","content":"https://nishantpainter.com/img/og/functional-programming-memoization.png"}]]],null,null,null,null,null,null,[["$","meta",null,{"property":"og:type","content":"article"}],null,null,null,null,null,null]],[["$","meta",null,{"name":"twitter:card","content":"summary_large_image"}],null,null,null,null,["$","meta",null,{"name":"twitter:title","content":"Functional Programming - Memoization"}],["$","meta",null,{"name":"twitter:description","content":"Memoization is a technique used to store the result of the expensive function call in a cache and return them when the same input is used again rather than a fresh computation."}],[[["$","meta",null,{"name":"twitter:image","content":"https://nishantpainter.com/img/og/functional-programming-memoization.png"}]]],null,null],null,[null,[["$","link",null,{"rel":"icon","href":"/favicon.ico","type":"image/x-icon","sizes":"any"}]],[],null]]
d:I{"id":"6831","chunks":["519:static/chunks/519-a3b077c6f8d3e235.js","49:static/chunks/49-aaf7e9eaea2df6f0.js","215:static/chunks/215-778e6a8571e20536.js","861:static/chunks/861-51134c186efb5132.js","17:static/chunks/17-be20e367e8a4b979.js","1:static/chunks/1-e7ecfedc4d37742a.js","688:static/chunks/app/blogs/[slug]/page-58c72bf823524d24.js"],"name":"","async":false}
b:["$","$Ld",null,{"blog":{"title":"Functional Programming - Memoization","date":"$D2023-06-25T00:00:00.000Z","content":"\n# Memoization\n\nIt is a technique of storing results and returning them instead of computing them afresh each time. Function calls can be expensive and its computation can be time consuming. In order to speed up the process, memoization is used to store the result of the expensive function call in a cache and return them when the same input is used again rather than a fresh computation. \n\nMemoization speeds up program execution and optimizes computation, thereby improving CPU performance. It is also sometimes referred to as _tabling_.\n\nFor example, A _Fibonacci Sequence_ is a series of numbers starting from zero, followed by one, and progressing on the rule that the next number in the series is the summation of preceding two numbers.\n\n`[0,1,1,2,3,5,8,13,21,...]`\n\nBelow mentioned is a simple program to get the _nth element_ of the fibonacci series starting from the zeroth index.\n\n```\nconst fibonacci = (n) => {\n  return n === 0 ? 0 : n === 1 ? 1 : fibonacci(n - 1) + fibonacci(n - 2);\n};\n\nfibonacci(3) // 1\nfibonacci(4) // 2\nfibonacci(5) // 3\nfibonacci(6) // 5\n```\n\nIt will often be the case when the value of _n_ will be repeated, and each time a computation will be performed to get the _nth element_. This can be time consuming if the value of _n_ is a higher number.\n\nThe computation speed in such cases can be easily speed up using memoization. The program works by computing fibonacci of intermediate values and their summation to get the nth index. Using memoization the result of input can be cached and returned instantly when provided with the same input again.\n\nA pure memoization function can be implemented as below :\n\n```\nconst memoize = (f) => {\n  f.cache = f.cache || {};\n\n  return (...args) => {\n    const key = 'key_' + args.join('');\n\n    if (!f.cache[key]) {\n      f.cache[key] = f(...args);\n    }\n\n    return f.cache[key];\n  };\n};\n```\n\nUsing this function, fibonacci program can be memoized as mentioned below :\n\n```\nconst memoizedFibonacci = memoize(fibonacci);\n\nmemoizedFibonacci(5); // Computation\nmemoizedFibonacci(5); // Cache HIT\n```\n\nConsider computing the _5th element_ in the fibonacci series. It will compute and store caches for indexes, _[0,1,2,3,4]_. Next time when we try to compute the _6th element_ in fibonacci series, instead of fresh computation, the previous nth element for indices _[0,1,2,3,4]_ will be returned instantly and improves performance and reduces time.\n\n```\nmemoizedFibonacci(5);\n\nfibonacci(4); // Computation\nfibonacci(3); // Computation\nfibonacci(2); // Computation\nfibonacci(1); // Computation\nfibonacci(0); // Computation\n\nmemoizedFibonacci(6);\n\nfibonacci(5); // Computation\nfibonacci(4); // Cache HIT\nfibonacci(3); // Cache HIT\nfibonacci(2); // Cache HIT\nfibonacci(1); // Cache HIT\nfibonacci(0); // Cache HIT\n```\n\nTo summarize, *Memoization* is an optimization technique to speed up program execution by caching results of expensive computation and returning cached results when the function is called when already known inputs.","categories":["Programming","Functional Programming"]}}]
b:["$","$Ld",null,{"blog":{"title":"Functional Programming - Memoization","date":"$D2023-06-25T00:00:00.000Z","content":"\n# Memoization\n\nIt is a technique of storing results and returning them instead of computing them afresh each time. Function calls can be expensive and its computation can be time consuming. In order to speed up the process, memoization is used to store the result of the expensive function call in a cache and return them when the same input is used again rather than a fresh computation. \n\nMemoization speeds up program execution and optimizes computation, thereby improving CPU performance. It is also sometimes referred to as _tabling_.\n\nFor example, A _Fibonacci Sequence_ is a series of numbers starting from zero, followed by one, and progressing on the rule that the next number in the series is the summation of preceding two numbers.\n\n```\n[0,1,1,2,3,5,8,13,21,...]\n```\n\nBelow mentioned is a simple program to get the _nth element_ of the fibonacci series starting from the zeroth index.\n\n```\nconst fibonacci = (n) => {\n  return n === 0 ? 0 : n === 1 ? 1 : fibonacci(n - 1) + fibonacci(n - 2);\n};\n\nfibonacci(3) // 1\nfibonacci(4) // 2\nfibonacci(5) // 3\nfibonacci(6) // 5\n```\n\nIt will often be the case when the value of _n_ will be repeated, and each time a computation will be performed to get the _nth element_. This can be time consuming if the value of _n_ is a higher number.\n\nThe computation speed in such cases can be easily speed up using memoization. The program works by computing fibonacci of intermediate values and their summation to get the nth index. Using memoization the result of input can be cached and returned instantly when provided with the same input again.\n\nA pure memoization function can be implemented as below :\n\n```\nconst memoize = (f) => {\n  f.cache = f.cache || {};\n\n  return (...args) => {\n    const key = 'key_' + args.join('');\n\n    if (!f.cache[key]) {\n      f.cache[key] = f(...args);\n    }\n\n    return f.cache[key];\n  };\n};\n```\n\nUsing this function, fibonacci program can be memoized as mentioned below :\n\n```\nconst memoizedFibonacci = memoize(fibonacci);\n\nmemoizedFibonacci(5); // Computation\nmemoizedFibonacci(5); // Cache HIT\n```\n\nConsider computing the _5th element_ in the fibonacci series. It will compute and store caches for indexes, _[0,1,2,3,4]_. Next time when we try to compute the _6th element_ in fibonacci series, instead of fresh computation, the previous nth element for indices _[0,1,2,3,4]_ will be returned instantly and improves performance and reduces time.\n\n```\nmemoizedFibonacci(5);\n\nfibonacci(4); // Computation\nfibonacci(3); // Computation\nfibonacci(2); // Computation\nfibonacci(1); // Computation\nfibonacci(0); // Computation\n\nmemoizedFibonacci(6);\n\nfibonacci(5); // Computation\nfibonacci(4); // Cache HIT\nfibonacci(3); // Cache HIT\nfibonacci(2); // Cache HIT\nfibonacci(1); // Cache HIT\nfibonacci(0); // Cache HIT\n```\n\nTo summarize, *Memoization* is an optimization technique to speed up program execution by caching results of expensive computation and returning cached results when the function is called when already known inputs.","categories":["Programming","Functional Programming"]}}]
Loading

0 comments on commit bc25b1f

Please sign in to comment.