logoalt Hacker News

KK7NILtoday at 2:32 AM1 replyview on HN

Both arrays and (pure) functions are just mappings of inputs to outputs, this is why memoization is possible without any loss of functionality.

Whether storing (arrays) or computing (functions) is faster is a quirk of your hardware and use case.


Replies

Dylan16807today at 6:40 AM

Memoization is a different way around though. You're turning part of a function into an array and a traditional function is still in charge. It doesn't depend on arrays being functions.

I would also reject the idea that "Arrays are Functions" is equivalent to "Functions are Arrays". They're both true in a sense, but they're not the same statement.

show 1 reply