From: dblack@... Date: 2006-09-15T17:44:22+09:00 Subject: Re: How to collect over two arrays then look back to one? Hi -- On Thu, 14 Sep 2006, Peter Booth wrote: > I am reading Ruby for Rails and Ruby Cookbock and delighted by the > Array#find_all and Enumerable#collect methods. I'm wondering what the > idiomatic way to do the following is? > > Two parallel arrays A, B . For each element n of A for which f(An) is true, > is g(B[n-3:n+3]) true? Where B[n-3:n+3] refers to seven elements of B whose > position is centered over An' position. > > Can the block inside Enumerable#collect know it's position inside the > Enumerable? Can one collect two parallel arrays? To answer the first question: no. You are free to join Citizens for map_with_index, of which I am the founder and president :-) David -- David A. Black | dblack@wobblini.net Author of "Ruby for Rails" [1] | Ruby/Rails training & consultancy [3] DABlog (DAB's Weblog) [2] | Co-director, Ruby Central, Inc. [4] [1] http://www.manning.com/black | [3] http://www.rubypowerandlight.com [2] http://dablog.rubypal.com | [4] http://www.rubycentral.org