3 ms·
> Look at that, it's even doing memoization! That function takes no argument. I've never seen initializing a single variable and returning the result of that
by TacticalCoder 3y ago
> Look at that, it's even doing memoization!
That function takes no argument. I've never seen initializing a single variable and returning the result of that initialized variable from a function call taking no argument called "memoization".
Memoization is a specific type of caching with a space/time trade-off where the result of a particular (set of) input(s) are cached.
I find it quite a stretch to call initializing a single integer for a function taking no parameters "memoization". I'd just say the function's return value is "cached".
I mean: by kinda, sorta, bending the definition of memoization (for example by changing "caching the function's results based on the inputs" to "caching the only result for there's no input to the function") you could say that it is actually memoization but then I'd argue this is not a great example of what memoization is.
I may be wrong though.
- fasterthanlime 3y agoI mean it's a perfectly fine hill to die on, but I think "memoization for n=0 arguments" is cromulent. Or even "memoization for n=1 argument, which only has one possible value" (like a unit enum in Rust). I could see both positions being justifiable tbqh.
- TacticalCoder 3y agoYou guys may be right. I really honestly never ever thought it that way. No hill to die on (and I enjoyed TFA!) that said ^ ^
- quesera 3y agoWikipedia say: > an optimization technique used primarily to speed up computer programs by storing the results of expensive function calls and returning the cached result when the same inputs occur again "the same" could be none, default, or null, I think.