[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Important Algorithm Finally Ported.

hampton c

1/12/2006 5:07:00 PM

After months of work, gruelling hours, and a nice cup of coffee, the
world's most famous (and infamous) algorithm has been ported to the
ruby language!

{applause}

Thank you, thank you.

The Slim Shady algorithm is a deceptively simple algorithm which finds
use in many many aerospace and bio-informatics systems. Therefore, Ruby
may now stand proud as.... a..... ummm.... language to do those things.

Here is the algorithm...

def slim_shady_finder homies
homies.each do |some_guy|
return some_guy if (some_guy.name.eql? "Slim Shady")
end
return nil
end

Thank you, I know you all can tell how many hours of work have gone
into this conversion. For more information on the SSA and to see where
our implementation has been added... go to the Uncyclopedia.

http://uncyclopedia.org/wiki/Slim_Shady_Algorithm#The_Actual_Algorithm.27s_imple...

8 Answers

dblack

1/12/2006 5:14:00 PM

0

Chad Perrin

1/12/2006 5:30:00 PM

0

On Fri, Jan 13, 2006 at 02:08:07AM +0900, Hampton wrote:
> After months of work, gruelling hours, and a nice cup of coffee, the
> world's most famous (and infamous) algorithm has been ported to the
> ruby language!
>
> {applause}
>
> Thank you, thank you.
>
> The Slim Shady algorithm is a deceptively simple algorithm which finds
> use in many many aerospace and bio-informatics systems. Therefore, Ruby
> may now stand proud as.... a..... ummm.... language to do those things.
>
> Here is the algorithm...
>
> def slim_shady_finder homies
> homies.each do |some_guy|
> return some_guy if (some_guy.name.eql? "Slim Shady")
> end
> return nil
> end
>
> Thank you, I know you all can tell how many hours of work have gone
> into this conversion. For more information on the SSA and to see where
> our implementation has been added... go to the Uncyclopedia.

Oh, thank goodness. I can finally write that plzstandup.rb program.

--
Chad Perrin [ CCD CopyWrite | http://ccd.ap... ]

unix virus: If you're using a unixlike OS, please forward
this to 20 others and erase your system partition.


hampton c

1/12/2006 5:43:00 PM

0

David, I'm sorry to say that there is no way to ever improve upon the
code I write.

For, you see, I am the Savior of Ruby. Actually, I'm just kidding. I'm
really the King of Ruby.

Well, I was trying to use the do and no () to make it as ruby-esque as
possible. But, I do like your use of find... so feel free to change it
on that wiki.

dblack

1/12/2006 7:08:00 PM

0

Gavin Kistner

1/12/2006 7:27:00 PM

0

I think you missed a bit:

def slim_shady_finder( homies )
homies.find{ |some_guy| some_guy.name.eql?( "Slim Shady" ) and not
some_guy.imitating? }
end

Ross Bamford

1/12/2006 8:54:00 PM

0

On Thu, 12 Jan 2006 19:26:40 -0000, Phrogz <gavin@refinery.com> wrote:

> I think you missed a bit:
>
> def slim_shady_finder( homies )
> homies.find{ |some_guy| some_guy.name.eql?( "Slim Shady" ) and not
> some_guy.imitating? }
> end
>

This is so important, I think we should do it *really* slowly and
carefully.

def find_slim(homies)
if (real_slim = homies.select do |guy|
guy.name.eql?('Slim Shady')
end.reject do |guy|
guy.respond_to?(:imitate_shady)
end.each do |guy|
guy.send(:please_stand_up, Time.now)
end).length == 1
real_slim.first
else
homies.shady_missing(:real_slim)
end
end

--
Ross Bamford - rosco@roscopeco.remove.co.uk

Sam Gentle

1/12/2006 9:06:00 PM

0

On 1/13/06, Phrogz <gavin@refinery.com> wrote:
> I think you missed a bit:
>
> def slim_shady_finder( homies )
> homies.find{ |some_guy| some_guy.name.eql?( "Slim Shady" ) and not
> some_guy.imitating? }
> end

But surely you can't just know if a slim shady is just imitating
without first asking them to stand up.

Perhaps:

slim_shadies.find { |slim_shady| slim_shady.stand_up_unless {
slim_shady.imitating? } }

Of course, that has problems - for one, it messes up the shadies'
persistent 'standing' state. This could cause serious problems with
false negatives if they were asked to "please stand up" twice in a
row. It might be possible to subsequently make them sit again, but the
whole thing loses thread safety easily (what if two programs
simultaneously need to find the real slim shady?).

To top it all off, there are potential accessibility issues for
disabled slim shadies who are unable to stand. I consider this
particularly likely to become a problem if every person is a slim
shady lurking. I think the only real solution here is to accept that
there is a slim shady in all of us and make slim_shady_finder simply
return nil.

Sam


hampton c

1/13/2006 1:23:00 PM

0

And this is why its such an important algorithm for so many sciences.