From: Paul Prescod Date: 2001-10-11T09:04:39+09:00 Subject: [ruby-talk:22411] Re: list comprehensions alike Python ??? Robert Feldt wrote: > >... > $ irb > irb(main):001:0> (1..11).map {|v| v*v} > [1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121] > > Short enough for my taste... (but maybe there are some benefits to the > Python way? I don't know any Python.) Out of curiousity, what would the Ruby for this look like: >>> arr = [x*x for x in range(0,10) if x%2==0] >>> arr [0, 4, 16, 36, 64] A combination of filter and map? Paul Prescod