标签:
var memoizer = function (memo, func) { var recur = function (n) { var result = memo[n]; if (typeof result !== ‘number‘) { result = func (recur, n); } return result; }; return recur; };
var fibonacci = memoizer([0, 1], function (recur, n) { return recur (n - 1) + recur(n - 2); });
标签:
原文地址:http://www.cnblogs.com/angelfan/p/4180802.html