I need a function that takes a rule/condition as an input. for example given an array of integers detect all the numbers that are greater than two, and all the numbers greater than four. I know this can be achieved easily without a function, but I need this to be inside a function. The function I would like to have is like
def _select(x,rule):
outp = rule(x)
return outp
L = np.round(np.random.normal(2,4,50),decimals=2)
y = _select(x=L,rule=(>2))
y1 = _select(x=L,rule=(>4))
How should I code a function like this?