mvarconcept.nim 334 B

1234567891011121314
  1. type RNG* = concept var rng
  2. rng.randomUint32() is uint32
  3. type MersenneTwister* = object
  4. proc randomUint32*(self: var MersenneTwister): uint32 = 5
  5. proc randomInt*(rng: var RNG; max: Positive): Natural = 5
  6. var mersenneTwisterInst = MersenneTwister()
  7. proc randomInt*(max: Positive): Natural =
  8. mersenneTwisterInst.randomInt(max)