< :the previous in number
^ :the list in numerical order
> :the next in number
P :the previous (in thread)
N :the next (in thread)
|<:the top of this thread
>|:the next thread
^ :the parent (reply-to)
_:the child (an article replying to this)
>:the elder article having the same parent
<:the youger article having the same parent
---:split window and show thread lists
| :split window (vertically) and show thread lists
~ :close the thread frame
.:the index
..:the index of indices
Hi --
On Mon, 29 Aug 2005, SHIGETOMI, Takuhiko wrote:
> greetings, Daniel. true. 'next' works.
>
>> You can't easily go backwards, but skipping to the next is
>> as easy as saying `next'.
>
> on the other hand, and as your reference 'cannot easyily go backwards',
> 'next' forgets current object unless any variable on outside of the
> yieldee block.
>
> how about writing a special yielder like as below ..
>
> any-enumerable-object.sliding_each do |prev,this,next|
> ...
> end
>
> - could be really useful?
> - any other good name?
This might help you on this:
irb(main):003:0> require 'enumerator'
=> true
irb(main):004:0> [1,2,3,4,5,6].each_cons(2) {|x| p x }
[1, 2]
[2, 3]
[3, 4]
[4, 5]
[5, 6]
=> nil
irb(main):005:0> [1,2,3,4,5,6].each_cons(3) {|x| p x }
[1, 2, 3]
[2, 3, 4]
[3, 4, 5]
[4, 5, 6]
David
--
David A. Black
dblack / wobblini.net