Kinda quiet

Is it my imagination, or are things getting really quiet in this forum?
It seems that the “movers and shakers” in this forum have moved on to
better digs.

Patrick S. wrote:

Is it my imagination, or are things getting really quiet in this forum?
It seems that the “movers and shakers” in this forum have moved on to
better digs.

It’s quiet because emails from the mailing list aren’t coming through.
I’ve sent Andreas an email about it.

Now, not to get too high up on my soapbox here, but: if you notice
something like this, please say something. The forums are generally a
more newbie-oriented place, and it does no one any good to have people
who are checking out Ruby feel like their messages are going unanswered.
If we want to maintain Ruby’s friendly community (I certainly do:
remember “Matz is nice so we are nice”?), then, regardless of how some
of you might feel about the forums, we should at least let Andreas know
when the link appears to be down.

Okay, off the soapbox now.

-Justin

Patrick S. wrote:

Is it my imagination, or are things getting really quiet in this forum?
It seems that the “movers and shakers” in this forum have moved on to
better digs.

All the fuss is on various forums discussing individual Ruby projects.

Put another way, one wouldn’t want to post here if one of those forums
were
on-topic. Also, you might get flamed for posting here if one of those
forums
were on-topic.

Say I have an array that contains 144 strings. I want to divide the
array into
12 sub-arrays each containing 12 strings. What is the Ruby Way of doing
this?
I’ve looked at slice array[0…11] etc, but that seems a bit clunky.

Thank you,
Brad

On Nov 7, 2006, at 2:14 PM, Brad T. wrote:

Say I have an array that contains 144 strings. I want to divide the
array into
12 sub-arrays each containing 12 strings. What is the Ruby Way of
doing this?
I’ve looked at slice array[0…11] etc, but that seems a bit clunky.

If those are the 12 natural consecutive sub-arrays:

require ‘enumerator’

array.each_slice(12) do |x|
# …
end

– fxn

On 11/7/06, Brad T. [email protected] wrote:

Say I have an array that contains 144 strings. I want to divide the array into
12 sub-arrays each containing 12 strings. What is the Ruby Way of doing this?
I’ve looked at slice array[0…11] etc, but that seems a bit clunky.

Thank you,
Brad

require ‘enumerator’

ret = []
array.each_slice(12) {|a| ret << a}

Hi –

On Tue, 7 Nov 2006, Jan S. wrote:

require ‘enumerator’

ret = []
array.each_slice(12) {|a| ret << a}

I wish there were a nice way to do this without the temporary array.
One of the first add-on methods I ever wrote for my own use in Ruby
was “in_chunks_of”:

[1,2,3,4,5,6].in_chunks_of(2) => [ [1,2], [3,4], [5,6] ]

The ActiveSupport library has something similar (in_groups_of). I
think it would be a handy addition to Array.

David

On 07/11/06, Brad T. [email protected] wrote:

Say I have an array that contains 144 strings. I want to divide the array into
12 sub-arrays each containing 12 strings. What is the Ruby Way of doing this?
I’ve looked at slice array[0…11] etc, but that seems a bit clunky.

Thank you,
Brad

require ‘enumerator’
numbers = Array(0…143)
numbers.enum_slice(12).inject([]) do |array,slice|
array << slice
end

Farrel

On 07/11/06, Pit C. [email protected] wrote:

numbers.enum_slice(12).inject([]) do |array,slice|
array << slice
end

require “enumerator”
numbers = Array(0…143)
numbers.enum_slice(12).to_a

Regards,
Pit

That’s pretty cool

Farrel L. schrieb:

array << slice
end

require “enumerator”
numbers = Array(0…143)
numbers.enum_slice(12).to_a

Regards,
Pit

On 07.11.2006 14:21, Jan S. wrote:

array.each_slice(12) {|a| ret << a}
require ‘enumerator’

arr = Array.new 144, “x”
ret = arr.to_enum(:each_slice, 12).inject([]) {|a, *x| a << x}

Kind regards

robert

On 07.11.2006 15:46, Pit C. wrote:

Farrel, it was you who found the important method Enumerable#enum_slice.
I just added the standard Enumerable#to_a method. Plus, I’m sure Robert
K. is happy to see more and more people adding #inject to their toolbox :slight_smile:

Definitively!

robert - inject missionary - klemme

:wink:

Farrel L. schrieb:

numbers = Array(0…143)
numbers.enum_slice(12).inject([]) do |array,slice|
array << slice
end

require “enumerator”
numbers = Array(0…143)
numbers.enum_slice(12).to_a

That’s pretty cool

Farrel, it was you who found the important method Enumerable#enum_slice.
I just added the standard Enumerable#to_a method. Plus, I’m sure Robert
K. is happy to see more and more people adding #inject to their toolbox
:slight_smile:

Regards,
Pit