import sys
sys.dont_write_bytecode=True
from lib import *

@demo
def mediand():
  print median([1,2,3,4,5,6])
  print median([1,2,3,4,5])

@demo
def oned():
  "Get anything out of a list."
  resetSeed(1)
  print one(list('abcd'))

@demo
def fewd():
  "Get any 3 things out of a list."
  resetSeed(1)
  print few(list('abcd'),3)

@demo
def somed():
  "Sample from some dictionary weights."
  resetSeed(1)
  d= {'box':30,'circle':20,'line':10}
  out = []
  for key in some(d, 10):
    out += [key]
  print sorted(out)

@demo
def thingd():
  """
  Shows the auto print of a thing. Note:
  the _cache var not printed (since it can
  get VERY big).
  """
  eg = Sample()
  print eg

@demo
def structd():
  "Create an object holding data in some fields."
  x = Struct(lines=[], rows = 0, font='courier')
  x.rows += 1
  x.lines += ['a new line']
  print x

@demo
def sampled():
  "Keep 20 items out of one million."
  resetSeed(1)
  sample = Sample(size=20)
  for x in range(10**6):
    sample.seen(x)
  print sample.sorted()

if __name__ == '__main__' : 
  eval(cmd('copyleft()'))
