Sets the miss policy for an ordered hash. The miss policy is called when a key with no associated value is requested. The ordered hash is then populated with the value returned by the miss policy closure.
%ohash - the ordered hash to set the miss policy for
&closure - the miss policy closure.
When called, the closure receives the following arguments:
Argument Description $1 the ordered hash scalar $2 the original key (before string conversion)
# Memoization with Miss Policies: Fibonacci Sequence sub fib { local('%fhash'); %fhash = ohash(0 => 0L, 1 => 1L); setMissPolicy(%fhash, { return $1[$2 - 1] + $1[$2 - 2]; }); return %fhash[$1]; } println("fib[90]: " . fib(90L));
fib[90]: 2880067194370816120