From: Robert Klemme Date: 2003-07-23T18:03:08+09:00 Subject: A different Version of Enumerable#inject Apparently the other post got overlooked - and it had an error in the implementation. What do others think of this suggestion of a changed Enumerable#inject that uses a sliding window whose size is determined by the block's arity. With this implementation you can do the usual injection tricks plus everything that needs more than one argument: # ordered? enum.inject(true) {|c,a,b|c&&a1 args args=[] each do |e| args.push e if args.length == size val = yield val, *args args.shift end end end val end end