What is the difference between inject and reduce methods

Rubysters,

I often use inject method (where and when I want to. Lol!). I would like to
know the difference between inject and reduce methods. I find them similar.

Ref: http://www.ruby-doc.org/core/classes/Enumerable.html#M001495

···

---
Edmond
Software Developer | Baobab Health Trust (http://www.baobabhealth.org/) |
Malawi

Cell: +265 999 465 137 | +265 881 234 717

*Prosperous New Year 2011 and Prosperous New Decade!!*

I often use inject method (where and when I want to. Lol!). I would like to
know the difference between inject and reduce methods. I find them similar.

They are the same. reduce is an alias for inject.

···

--
Anurag Priyam
http://about.me/yeban/

They are the same, I think the names are just to make people from different
languages feel at home. I think "inject" is from Smalltalk, and "reduce" is
from Common Lisp, and IIRC "fold" is from Scheme and Haskell.

Interestingly, at the last RubyConf, Aaron Patterson and Rein Henrichs were
giving their presentations simultaneously, in different rooms, and both of
them criticized the use of this method :stuck_out_tongue:

···

On Thu, Jan 13, 2011 at 1:59 AM, Edmond Kachale < edmond.kachale@baobabhealth.org> wrote:

Rubysters,

I often use inject method (where and when I want to. Lol!). I would like to
know the difference between inject and reduce methods. I find them similar.

Ref: module Enumerable - RDoc Documentation

---
Edmond
Software Developer | Baobab Health Trust (http://www.baobabhealth.org/\) |
Malawi

Cell: +265 999 465 137 | +265 881 234 717

*Prosperous New Year 2011 and Prosperous New Decade!!*

http://talklikeaduck.denhaven2.com/2010/11/26/how-arlo-got-injected-into-ruby

···

On Thu, Jan 13, 2011 at 6:30 AM, Josh Cheek <josh.cheek@gmail.com> wrote:

They are the same, I think the names are just to make people from different
languages feel at home. I think "inject" is from Smalltalk, and "reduce" is
from Common Lisp, and IIRC "fold" is from Scheme and Haskell.

Interestingly, at the last RubyConf, Aaron Patterson and Rein Henrichs were
giving their presentations simultaneously, in different rooms, and both of
them criticized the use of this method :stuck_out_tongue:

--
Rick DeNatale

Blog: http://talklikeaduck.denhaven2.com/
Github: rubyredrick (Rick DeNatale) · GitHub
Twitter: @RickDeNatale
WWR: http://www.workingwithrails.com/person/9021-rick-denatale
LinkedIn: http://www.linkedin.com/in/rickdenatale

Rick DeNatale wrote:

···

On Thu, Jan 13, 2011 at 6:30 AM, Josh Cheek <josh.cheek@gmail.com> wrote:

They are the same, I think the names are just to make people from different
languages feel at home. I think "inject" is from Smalltalk, and "reduce" is
from Common Lisp, and IIRC "fold" is from Scheme and Haskell.

Interestingly, at the last RubyConf, Aaron Patterson and Rein Henrichs were
giving their presentations simultaneously, in different rooms, and both of
them criticized the use of this method :stuck_out_tongue:

http://talklikeaduck.denhaven2.com/2010/11/26/how-arlo-got-injected-into-ruby

Note that Iverson's notation in "A Programming Language"(Wiley, 1962) contained "reduction" operations to extend an operation such as multiplication over all components of a vector or matrix. APL programmers commonly pronounce an expression like "+/v" as "plus reduce v".

Thanks for the Alice's Restaurant connection.

-- Bill

Hah, I went and listened to that song, it was awesome!

···

On Thu, Jan 13, 2011 at 6:33 AM, Rick DeNatale <rick.denatale@gmail.com>wrote:

On Thu, Jan 13, 2011 at 6:30 AM, Josh Cheek <josh.cheek@gmail.com> wrote:

> They are the same, I think the names are just to make people from
different
> languages feel at home. I think "inject" is from Smalltalk, and "reduce"
is
> from Common Lisp, and IIRC "fold" is from Scheme and Haskell.
>
> Interestingly, at the last RubyConf, Aaron Patterson and Rein Henrichs
were
> giving their presentations simultaneously, in different rooms, and both
of
> them criticized the use of this method :stuck_out_tongue:
>

http://talklikeaduck.denhaven2.com/2010/11/26/how-arlo-got-injected-into-ruby