[#15707] Schedule for the 1.8.7 release — "Akinori MUSHA" <knu@...>

Hi, developers,

21 messages 2008/03/01

[#15740] Copy-on-write friendly garbage collector — Hongli Lai <hongli@...99.net>

Hi.

31 messages 2008/03/03
[#15742] Re: Copy-on-write friendly garbage collector — Yukihiro Matsumoto <matz@...> 2008/03/03

Hi,

[#15829] Re: Copy-on-write friendly garbage collector — Daniel DeLorme <dan-ml@...42.com> 2008/03/08

Yukihiro Matsumoto wrote:

[#15756] embedding Ruby 1.9.0 inside pthread — "Suraj Kurapati" <sunaku@...>

Hello,

18 messages 2008/03/03
[#15759] Re: embedding Ruby 1.9.0 inside pthread — Nobuyoshi Nakada <nobu@...> 2008/03/04

Hi,

[#15760] Re: embedding Ruby 1.9.0 inside pthread — Yukihiro Matsumoto <matz@...> 2008/03/04

Hi,

[#15762] Re: embedding Ruby 1.9.0 inside pthread — "Suraj N. Kurapati" <sunaku@...> 2008/03/04

Yukihiro Matsumoto wrote:

[#15783] Adding startup and shutdown to Test::Unit — Daniel Berger <Daniel.Berger@...>

Hi all,

15 messages 2008/03/04

[#15835] TimeoutError in core, timeouts for ConditionVariable#wait — MenTaLguY <mental@...>

I've been reworking JRuby's stdlib to improve performance and fix

10 messages 2008/03/09

[#15990] Recent changes in Range#step behavior — "Vladimir Sizikov" <vsizikov@...>

Hi,

35 messages 2008/03/23
[#15991] Re: Recent changes in Range#step behavior — Dave Thomas <dave@...> 2008/03/23

[#15993] Re: Recent changes in Range#step behavior — "Vladimir Sizikov" <vsizikov@...> 2008/03/23

Hi Dave,

[#15997] Re: Recent changes in Range#step behavior — Dave Thomas <dave@...> 2008/03/23

[#16024] Re: Recent changes in Range#step behavior — "Vladimir Sizikov" <vsizikov@...> 2008/03/26

Hi Dave,

[#16025] Re: Recent changes in Range#step behavior — Yukihiro Matsumoto <matz@...> 2008/03/26

Hi,

[#16026] Re: Recent changes in Range#step behavior — Dave Thomas <dave@...> 2008/03/26

[#16027] Re: Recent changes in Range#step behavior — Yukihiro Matsumoto <matz@...> 2008/03/26

Hi,

[#16029] Re: Recent changes in Range#step behavior — Dave Thomas <dave@...> 2008/03/26

[#16030] Re: Recent changes in Range#step behavior — Yukihiro Matsumoto <matz@...> 2008/03/26

Hi,

[#16031] Re: Recent changes in Range#step behavior — Dave Thomas <dave@...> 2008/03/26

[#16032] Re: Recent changes in Range#step behavior — "Vladimir Sizikov" <vsizikov@...> 2008/03/26

On Wed, Mar 26, 2008 at 7:01 PM, Dave Thomas <dave@pragprog.com> wrote:

[#16033] Re: Recent changes in Range#step behavior — Dave Thomas <dave@...> 2008/03/26

[#16041] Re: Recent changes in Range#step behavior — David Flanagan <david@...> 2008/03/26

Dave Thomas wrote:

Re: Questions on Enumerator#skip_first and Enumerable#first

From: "Artem Voroztsov" <artem.voroztsov@...>
Date: 2008-03-18 15:14:50 UTC
List: ruby-core #15950
2008/3/18, James Gray <james@grayproductions.net>:
> On Mar 18, 2008, at 6:20 AM, Artem Voroztsov wrote:
>
>  > I asked in ruby-talk, but did not get answer.
>
>
> I remember answering you:
>
>    http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/294422
>
>  ;)


1)

I am asking what is wrong with my code and what is the correct way to
write this method for enumerator in Ruby.


See, l we have the following
$  time ./ruby -e '(1..100000000).each.drop(2).take(5).each{|e| puts e}'
3
4
5
6
7
real     0m12.029s
user    0m11.546s
sys     0m0.585s


So it looks like 'drop' and 'take' has call 'to_a' inside.

I am asking about method 'drop' for Enumerator which just skips some
elements without creating new array.

I would like to think about Enumerator as iterator in STL.

I guest Enumerator should display conventional pipe behavior (see
'tail' and  'head' commands in Unix).


Both 'drop' and 'take' methods are slow for big collections:

$  time ./ruby -ve 'i =4; (1..100000000).each.drop(2).each{|e| puts e;
break if i==0; i-=1}'
ruby 1.9.0 (2008-03-18 revision 15793) [i686-linux]
3
4
5
6
7

real    0m11.967s
user    0m11.485s
sys     0m0.568s

$ time ./ruby -ve 'i =4; (1..100000000).each.take(100000000).each{|e|
puts e; break if i==0; i-=1}'
ruby 1.9.0 (2008-03-18 revision 15793) [i686-linux]
1
2
3
4
5

real    0m11.396s
user    0m10.929s
sys     0m0.490s


2) I am sorry. I've  found that method Enumerable#first is in trunk.


Artem

In This Thread