an interesting one-liner to ponder

Discussion in 'Ruby' started by John Joyce, Nov 17, 2007.

  1. John Joyce

    John Joyce Guest

    Here's an interesting one-liner to ponder.

    0.step(100, rand) { |x| puts x }

    Think of timers, for games or whatever, you could easily alter the
    pseudo-random stepping increment to make it bigger but random, or
    have broader ranges of randomness.

    The interval will not be obvious to the user.
     
    John Joyce, Nov 17, 2007
    #1
    1. Advertising

  2. 2007/11/17, John Joyce <>:
    > Here's an interesting one-liner to ponder.
    >
    > 0.step(100, rand) { |x| puts x }
    >
    > Think of timers, for games or whatever, you could easily alter the
    > pseudo-random stepping increment to make it bigger but random, or
    > have broader ranges of randomness.
    >
    > The interval will not be obvious to the user.


    But constant. I am not sure I understand what this is good for. Can
    you share your ideas?

    Kind regards

    robert


    --
    use.inject do |as, often| as.you_can - without end
     
    Robert Klemme, Nov 17, 2007
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Girish
    Replies:
    1
    Views:
    352
    Marina
    Jan 23, 2004
  2. Mantorok Redgormor

    bitwise increment one liner

    Mantorok Redgormor, Dec 17, 2003, in forum: C Programming
    Replies:
    8
    Views:
    817
    Peter Shaggy Haywood
    Dec 19, 2003
  3. =?ISO-8859-1?Q?Morris_Carr=E9?=

    Python passes the Turing test with a one-liner !

    =?ISO-8859-1?Q?Morris_Carr=E9?=, Apr 1, 2004, in forum: Python
    Replies:
    1
    Views:
    344
    Jon Perez
    Apr 2, 2004
  4. Paul Watson

    Using for in one-liner

    Paul Watson, Aug 15, 2005, in forum: Python
    Replies:
    8
    Views:
    595
    Reinhold Birkenfeld
    Aug 17, 2005
  5. Larry
    Replies:
    1
    Views:
    103
    Martien Verbruggen
    Feb 3, 2005
Loading...

Share This Page