[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

Deaf Calculus

Luke Kyrchner

6/4/2009 5:58:00 PM

Hey, I am trying a variation of Deaf Grandma program that takes off of
Tintin's Character Professor Calculus. I tried to make it... But it did
not work very well. Any help/advice?

Attachments:
http://www.ruby-...attachment/3781/C...

--
Posted via http://www.ruby-....

4 Answers

Luke Kyrchner

6/4/2009 6:09:00 PM

0

Luke Kyrchner wrote:
Okay, I just figured one thing out:
Instead of putting .capitalize, you put .upcase
What I would like to know is how to put in a random sentence, like you
make 7 different sentences, how could you make the program put a
sentence at random instead of a date?


Attachments:
http://www.ruby-...attachment/3782/C...

--
Posted via http://www.ruby-....

Todd Benson

6/4/2009 8:41:00 PM

0

On Thu, Jun 4, 2009 at 1:08 PM, Luke Kyrchner <lynx557@gmail.com> wrote:
> Luke Kyrchner wrote:
> Okay, I just figured one thing out:
> Instead of putting .capitalize, you put .upcase
> What I would like to know is how to put in a random sentence, like you
> make 7 different sentences, how could you make the program put a
> sentence at random instead of a date?

Just a hint.

'daygs' used for "Snatch" reference :)...

array = ["Ya like daygs?", "Do I like daygs?", "Yeah, d'ya like
daygs", "Oh, 'do I like dahgs.'", "Yeah, I like dahgs."]
puts array[rand(array.size - 1)]

Todd

Brian Candler

6/4/2009 8:56:00 PM

0

Todd Benson wrote:
> array = ["Ya like daygs?", "Do I like daygs?", "Yeah, d'ya like
> daygs", "Oh, 'do I like dahgs.'", "Yeah, I like dahgs."]
> puts array[rand(array.size - 1)]

I think you want puts array[rand(array.size)], otherwise the last
element won't ever be used.

------------------------------------------------------------ Kernel#rand
rand(max=0) => number
------------------------------------------------------------------------
Converts _max_ to an integer using max1 = max+.to_i.abs+. If the
result is zero, returns a pseudorandom floating point number
greater than or equal to 0.0 and less than 1.0. Otherwise, returns
a pseudorandom integer greater than or equal to zero and less than
max1.
--
Posted via http://www.ruby-....

Todd Benson

6/4/2009 11:14:00 PM

0

On Thu, Jun 4, 2009 at 3:56 PM, Brian Candler <b.candler@pobox.com> wrote:
> Todd Benson wrote:
>> array = ["Ya like daygs?", "Do I like daygs?", "Yeah, d'ya like
>> daygs", "Oh, 'do I like dahgs.'", "Yeah, I like dahgs."]
>> puts array[rand(array.size - 1)]
>
> I think you want puts array[rand(array.size)], otherwise the last
> element won't ever be used.

Yes, yes; must read the docs before responding :-)