Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

New function by adding two functions

Tags:

julia

Is it possible to create a new function from the addition of two other functions in Julia? I want to do something like this:

function quadratic(x)
  return x^2
end

function cubic(x)
  return x^3
end

f::Function = quadratic + cubic
# such that f(x) returns x^2 + x^3

like image 229
operator Avatar asked Dec 10 '25 04:12

operator


1 Answers

There is the less magic solution which is f(x) = quadratic(x) + cubic(x)

like image 154
Oscar Smith Avatar answered Dec 13 '25 00:12

Oscar Smith



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!