Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In Ruby, why is the accumulator called memo in the inject/reduce methods?

Tags:

ruby

Out of curiosity, why is the accumulator called memo in the inject/reduce methods? Is there some context/history behind its naming? Does it actually mean "memo" or does memo stand for something?

http://ruby-doc.org/core-2.0/Enumerable.html#method-i-inject

http://ruby-doc.org/core-2.0/Enumerable.html#method-i-reduce

like image 367
khoomeister Avatar asked Aug 15 '13 19:08

khoomeister


1 Answers

"memo" means in memory,that inject uses throughout its full iteration to hold the intermediate object state,to use it for its next iteration.

like image 127
Arup Rakshit Avatar answered Oct 05 '22 04:10

Arup Rakshit