0

I am trying to evaluate the following type of expression

max(0,x_2-1)

for an interval of values of x_2.

The final objective is to be able to obtain a plot of an expression of the form

max(0,x_2-1) >= max(x_1,x_3-1)

I don't think python has any built in function to do this, so I was trying to write my own function but I am not sure how to write a function that has another function, like x_2-1, as input.

Could anyone tell me how to solve this issue?

1
  • You can pass functions as parameters to other functions in the same way as you would pass anything else: def foo(f): print(f(2)), def bar(x): return x*2, foo(bar) Commented May 11, 2017 at 15:27

1 Answer 1

2

Functions are objects in python:

def foo(x, fxn):
    return fxn(x) + 5

def bar(x):
    return x + 10

print(foo(2, bar))

prints 17

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.