from math import sqrt,sin; import functools as ft; #------------------------------------------------------------------------------# def unit(x): return x; def bind(x,f): if x==None: return None; else: return f(x); # end def #------------------------------------------------------------------------------# def fSqrt(x): if x<0: return None; else: return sqrt(x); mSqare=ft.partial(bind,f=fSqrt); mSin=ft.partial(bind,f=sin); x=4; y=mSqare(x); assert y==2.0 x=-1; y=mSqare(x); assert y==None; x=-1; y=mSqare(x); y=mSin(y); assert y==None;