Pass function as parameter 2 : Function as Parameters : Function : Python examples (example source code) Organized by topic

C++
PHP
Python
Python Home »  Function   » [  Function as Parameters  ]  Screenshots 
 



Pass function as parameter 2




def minmax(test, *args):
    res = args[0]
    for arg in args[1:]:
        if test(arg, res):
            res = arg
    return res

def lessthan(x, y)return x < y     
def grtrthan(x, y)return x > y

print minmax(lessthan, 421563)
print minmax(grtrthan, 421563)

           
       
Related examples in the same category
























Home| Contact Us
Copyright 2003 - 04 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.