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 |
/usr/share/Macaulay2/Core/methods.m2:658:18-666: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))
The object stashValue is a function closure.