i1 : x = new MutableHashTable from { val => 1000 }
o1 = MutableHashTable{...1...}
o1 : MutableHashTable
|
i2 : f = (t -> (print "hi there"; t.val^4)) o2 = f o2 : FunctionClosure |
i3 : h = (stashValue VALUE) f
o3 = {*a cache function*}
o3 : CacheFunction
|
i4 : h x hi there o4 = 1000000000000 |
i5 : h x o5 = 1000000000000 |
i6 : peek x
o6 = MutableHashTable{val => 1000 }
VALUE => 1000000000000
|
../../m2/methods.m2:516:18-524:26: --source code:
stashValue = key -> f -> new CacheFunction from (x -> (
if x#?key then (
val := x#key;
if class val === CacheFunction then (
remove(x,key);
x#key = val x)
else val
)
else x#key = f x))