memorizes a function's return value up-until n-calls,
and after this, unmemorized call arguments will either return the optional default_value (if it was provided),
or it will return value of the nth call (final call that got memorized).
assertEq(memorized_fn("a camel") , "you owe a camel to the bank.") assertEq(fn_call_count , 1) assertEq(memorized_fn("a camel") , "you owe a camel to the bank.") assertEq(fn_call_count , 1) assertEq(memorized_fn("5") , "you owe 5 to the bank.") assertEq(fn_call_count , 2) // from here on, memorization will be halted and only `"DEFAULT VALUE!"` will be returned for unmemorized args assertEq(memorized_fn("5") , "you owe 5 to the bank.") assertEq(fn_call_count , 2) assertEq(memorized_fn(5) , "DEFAULT VALUE!") assertEq(fn_call_count , 2) assertEq(memorized_fn("your soul"), "DEFAULT VALUE!") assertEq(fn_call_count , 2) assertEq(memorized_fn("your soul"), "DEFAULT VALUE!") assertEq(fn_call_count , 2) assertEq(memorized_fn("a camel") , "you owe a camel to the bank.") assertEq(fn_call_count , 2)
memorizes a function's return value up-until
n
-calls, and after this, unmemorized call arguments will either return the optionaldefault_value
(if it was provided), or it will return value of then
th call (final call that got memorized).Example