#inject and slowness

I've often heard Ruby's inject method criticized as being "slow." As I rather like the function, and see equivalents in other languages, I'm curious if it's merely Ruby's implementation of the method that's slow, or if it is inherently a slow way to do things (e.g. should be avoided for non-small collections)?

Answers


inject is like fold, and can be very efficient in other languages, fold_left specifically, since it's tail-recursive.


Need Your Help

UITableView scrolling but not as expected?

ios uitableview scroll

I have a tableview and there are loads of element in it, when i scroll down, it does not stay where i left the scroll, it again goes to top.

Confused about ANOVA in R

r csv lm anova

I am new to R and statistics and am trying to do two-factor ANOVA on a dataset in csv file where values of each factor are in its own column. I was using

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.