// description of your code here
package
{
public class Memo
{
static public function Memoize(obj:*, func:Function):Function
{
// *** Each argument to func must provide a unique value when
// *** converted to a string. For example, something that just
// *** prints out as [Object] will not work.
var hash:Object = {};
var f:Function = function(...args):*
{
// Check hash for result.
var key:String = args.join(",");
var result:* = hash[key];
if (result == null)
{
result = func.apply(obj, args);
hash[key] = result;
}
return result;
}
return f;
}
}
}