summaryrefslogtreecommitdiff
path: root/zsh/Functions/memoize
diff options
context:
space:
mode:
authorNick Shipp <nick@shipp.ninja>2017-02-14 08:41:16 -0500
committerNick Shipp <nick@shipp.ninja>2017-02-14 08:41:16 -0500
commit24a605577c8e09a75f8f717f9df1bdc6c8dd8ec3 (patch)
tree794db72af4e1ddf41cff2d1f6371b27103562d69 /zsh/Functions/memoize
initial commit
Diffstat (limited to 'zsh/Functions/memoize')
-rw-r--r--zsh/Functions/memoize11
1 files changed, 11 insertions, 0 deletions
diff --git a/zsh/Functions/memoize b/zsh/Functions/memoize
new file mode 100644
index 0000000..c58e65d
--- /dev/null
+++ b/zsh/Functions/memoize
@@ -0,0 +1,11 @@
+if ((! $+MEMOIZE)) {
+ declare -Ag MEMOIZE
+}
+
+if (($+MEMOIZE[$*])) {
+ printf '%s' "$MEMOIZE[$*]"
+ return
+}
+
+MEMOIZE[$*]=$(eval $*)
+printf '%s' "$MEMOIZE[$*]"