高階函數python
不相等
自定義sort函數app
內建函數--高階函數函數
#sort函數 def sort2(lst,key = None,reverse = False): res = [] if key is None: key =lambda x,y:x<y if reverse: key = lambda x,y:x>y for x in lst: for j,y in enumerate(res): if key(x,y): res.insert(j,x) break else: res.append(x) return res
def filter1(predict,lst):#filter1至關於(item for item in iterable if function(item)) if predict is None: predict = bool for i in lst: if predict(i): yield i
#簡單實現map函數 def map1(predict,lst): for args in lst: yield predict(*args)
柯里化Curryingspa
裝飾器3d
文檔字符串code
帶參數的裝飾器blog
functools模塊文檔