#!/usr/bin/env python
'''
$Id: numconv.py,v 1.2 2000/05/03 23:13:52 wesc Exp $

numconv.py -- convert sequence of numbers to same the type using built-ins
'''

# convert() --> sequence
def convert(func, seq):
    'convert(func, seq) -- convert sequence of numbers to same the type'
    newSeq = []
    for eachNum in seq:
        newSeq.append(func(eachNum))
    return newSeq


# test() --> void
def test():
    'test() -- test calling function references'
    myseq = (123, 45.67, -6.2e8, 999999999L)
    bifs = (int, long, float)
    for eachBIF in bifs:
	# all built-in functions have string name attributes (see 14.1.1)
	print 'invoking %5s():\t' % (eachBIF.__name__),
	print convert(eachBIF, myseq)


# call test() if invoked as a script
if __name__ == '__main__':
    test()

