From: Daniel Berger Date: 2002-11-15T04:01:36+09:00 Subject: Re: Ruby equivalent to Python's map()? Phil Tomson wrote: > In article <82c04a2.0211140526.115c9413@posting.google.com>, > Roberto Amorim wrote: > >Hi... > > > >I'm a Python programmer and I'm trying Ruby now. I love Smalltalk and > >Ruby's "OO-ness" and likeness to Smalltalk gives me warm feelings. I'm > >really excited about Ruby, enough to consider switching to it from > >Python. > > > >However, I was messing around yesterday with Ruby and looked > >everywhere for some functionality close to the map() function on > >python, but couldn't find it anywhere. For those that don't know the > >function, here's a raw example: > > > >a = [1,2,3] > >b = [4,5,6] > >map(None, a, b) --> [[1,4],[2,5],[3,6]] > > > > Hmmm... this seems to be what the proposed 'zip' method on Array would do. > It's not included yet, but apparently has been approved. > > I'm not sure that 'zip' is the best name, though... > > Phil Third party modules ok? require "hashslice" c[*a] = *b c.to_a -> [[1, 4], [2, 5], [3, 6]] Regards, Dan