diff options
| author | Nick Shipp <nick@shipp.ninja> | 2017-02-14 08:41:16 -0500 | 
|---|---|---|
| committer | Nick Shipp <nick@shipp.ninja> | 2017-02-14 08:41:16 -0500 | 
| commit | 24a605577c8e09a75f8f717f9df1bdc6c8dd8ec3 (patch) | |
| tree | 794db72af4e1ddf41cff2d1f6371b27103562d69 /zsh/Functions/memoize | |
initial commit
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[$*]"  | 
