why memoization is not a language feature?

后端 未结 11 618
无人及你
无人及你 2021-01-31 09:00

I was wondering... why memoization is not provided natively as a language feature by any language I know about?

Edit: to clarify, what I mean is that th

11条回答
  •  粉色の甜心
    2021-01-31 09:02

    Clojure has a memoize function (http://richhickey.github.com/clojure/clojure.core-api.html#clojure.core/memoize):

    memoize
    function
    
    Usage: (memoize f)
    
    Returns a memoized version of a referentially transparent function. The
    memoized version of the function keeps a cache of the mapping from arguments
    to results and, when calls with the same arguments are repeated often, has
    higher performance at the expense of higher memory use.
    

提交回复
热议问题