summaryrefslogtreecommitdiff
path: root/zsh/Functions/memoize
blob: c58e65da1c69a20d55764560d283c82dd434a6f1 (plain)
1
2
3
4
5
6
7
8
9
10
11
if ((! $+MEMOIZE)) {
    declare -Ag MEMOIZE
}

if (($+MEMOIZE[$*])) {
    printf '%s' "$MEMOIZE[$*]"
    return
}

MEMOIZE[$*]=$(eval $*)
printf '%s' "$MEMOIZE[$*]"