diff options
Diffstat (limited to 'zsh/Functions/memoize')
-rw-r--r-- | zsh/Functions/memoize | 11 |
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[$*]" |