From: Ryan Leavengood on 3 May 2007 10:25
On 5/3/07, Rick DeNatale <rick.denatale(a)gmail.com> wrote:
> After seeing the neat use of each_slice instead of each_with_index
> def luhn(string)
> string.scan(/./).reverse.enum_for(:each_slice, 2).inject(0) do |sum, (d1, d2)|
> sum += d1.to_i + (d2||'0').tr('0123456789', '0246813579').to_i
> end % 10 == 0
> No need to define any extra Enumerator methods.
Nice, I like it. When I first thought about using
enum_for(:each_slice, 2) I was surprised that it even worked.
Enumerator is a powerful library.
It seems like I learn something new every time I do one of these
quizzes, either from making my own solution or reading someone else's.
From: James Edward Gray II on 3 May 2007 10:29
On May 3, 2007, at 9:15 AM, anansi wrote:
>> Ruby Quiz will now take a one week break. Work has been rough
>> this week and I
>> need some down time. I'll be back next week, rested, and with new
> Means that: no quiz tomorrow ?!?
Yes. I need a short break. We will have one the following Friday
James Edward Gray II
From: Rick DeNatale on 3 May 2007 10:33
On 5/3/07, Ryan Leavengood <leavengood(a)gmail.com> wrote:
> Enumerator is a powerful library.
Yep. And personally, I like the fact that Ruby 1.9 is on the path to:
1) Move enumerator to the core classes.
2) Have enumerator methods return an enumerator if they are called
without a block.
The second one seems to be slightly controversial, but I love it.
My blog on Ruby
From: anansi on 3 May 2007 10:34
James Edward Gray II wrote:
> On May 3, 2007, at 9:15 AM, anansi wrote:
>>> Ruby Quiz will now take a one week break. Work has been rough this
>>> week and I
>>> need some down time. I'll be back next week, rested, and with new
>> Means that: no quiz tomorrow ?!?
> Yes. I need a short break. We will have one the following Friday though.
> James Edward Gray II
Maybe someone is interested or has an idea for an unoffical Ruby Quiz
for this week. I'm bored , so If someone has any idea, feel free to drop
/\ .-"""-. /\
//\\/ ,,, \//\\
|/\| ,;;;;;, |/\|
// \/ . \/ \\
(| ,-_| \ | / |_-, |)
// /.-(() ())-.\ \\
(\ |) '---' (| /)
` (| |) `
jgs \) (/
one must still have chaos in oneself to be able to give birth to a
From: Puria Nafisi Azizi on 3 May 2007 11:04
> Maybe someone is interested or has an idea for an unoffical Ruby Quiz
> for this week. I'm bored , so If someone has any idea, feel free to drop
conway's game of life?