From: Vitor Peres Date: 2007-11-28T21:46:36+09:00 Subject: Re: Ruby needs continuations... ------=_Part_2249_4651651.1196253998737 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-Disposition: inline On Nov 28, 2007 10:30 AM, Just Another Victim of the Ambient Morality < ihatespam@hotmail.com> wrote: > > How would one do this in Ruby? You can use .each_with_index and index > the other list but that assumes that the other list is indexable, which > only > happens to be true of arrays but is not true in general. I've thought > about > implementing some Ruby equivalent of zip() (or preferably izip()) and > discovered that I can't do so without continuations. > I can't comment much on the rest of your post, considering I lack knowledge both on the Python camp and the Ruby camp to make any meaningful consideration. Ruby does, however, have an implementation of zip in Enumerable. You can do list1 = [1, 2, 3, 4] list2 = ['a', 'b', 'c', 'd'] list1.zip(list2).each {|num, letter| puts "#{num} #{letter}" } just fine. You'll actually get the same result you would with your Python example. Best regards, Vitor ------=_Part_2249_4651651.1196253998737--