Module Racket::Misc
In: lib/racket/misc/lv.rb  (CVS)
lib/racket/misc/misc.rb  (CVS)
lib/racket/misc/vt.rb  (CVS)
lib/racket/misc/orderedhash.rb  (CVS)
lib/racket/misc/tlv.rb  (CVS)

Methods

Classes and Modules

Class Racket::Misc::LV
Class Racket::Misc::OrderedHash
Class Racket::Misc::TLV
Class Racket::Misc::VT

Public Class methods

Return a number that is at most size bits long

[Source]

# File lib/racket/misc/misc.rb, line 31
  def Misc.randbits(size)
    bits = 0
    srand Time.now.usec
    0.upto(size-1) {
      bits <<= 1
      bits |= rand(2)
    }
    bits
  end

Return a byte that is at most size bytes long

[Source]

# File lib/racket/misc/misc.rb, line 42
  def Misc.randbytes(size)
    bytes = 0
    0.upto(size-1) {
      bytes <<= 8
      bytes |= randbits(8)
    }
    bytes
  end

Return a string that is at most size characters long

[Source]

# File lib/racket/misc/misc.rb, line 52
  def Misc.randstring(size)
    s = ""
    0.upto(size-1) {
      s += sprintf("%c", randbytes(1))
    }
    s
  end

[Validate]