For some weird reason I was expecting reverse_each to be slower than
each, so I decided that reversing once and eaching multiple times would
be faster than multiple reverse_eaching - Benchmarking killed that myth
though. The saving however, is in the order of nanoseconds, as the
reverse only happens once.
Reversing an array with 10 elements took about a millionth of second on
my machine. Considering you're going to be iterating over 3.6 million
permutations, which takes somewhere in the order of 3 minutes, I decided
that extra optimisation wasn't necessary =)
I would have preferred if ((size-1)..0).each actually iterated, but
them's the breaks.
···
-----Original Message-----
From: Sean O'Halpin [mailto:sean.ohalpin@gmail.com]
Sent: Monday, 7 November 2005 11:36 AM
To: ruby-talk ML
Subject: Re: Fun with Permutations (including new change for Facets)On 11/7/05, Daniel Sheppard <daniels@pronto.com.au> wrote:
> s = (0...size).to_a.reverse
> ...
> break if s.each { |i|Did you know there is a reverse_each? Might shave off a
millisecond or twoRegards,
Sean
#####################################################################################
This email has been scanned by MailMarshal, an email content filter.
#####################################################################################