#!env python
from __future__ import print_function
from random import randint
def run(pred, f, somep, otherp, elsep):
def wrap(g):
def p(x):
result = f(x)
if result:
g()
return result
return p
def inrun(someproc, otherproc, elseproc):
p = pred()
if p == 0:
result = someproc(0)
elif p == 1:
result = otherproc(2)
else:
result = elseproc(4)
return result
return inrun(wrap(somep), wrap(otherp), wrap(elsep))
print(
run(
lambda: randint(0, 2)
, lambda x: x % 2 == 0
, lambda: print("some")
, lambda: print("other")
, lambda: print("else")
)
)