B.! @Carl Woll's answer is a great one, it would look like this:
Notice that you don't have to stick to the same naming convention for the expressions which you create another function for. Though, I may suggest a method that looks a bit fancier, and uses pure functions, which I prefer to use in code to save space, though with taking a hit on readability if the user is unfamiliar. Find it below:
Off hand, I don't know if it runs any faster or does much more than make you use pure functions, but hey! It's a different answer :D
Also notice that you don't necessarily need to use a
:= SetDelayed method of defining the function, and maybe this will help you come up with some neat tricks where you define the initial function one way, use this redefinition/reduction method to define
g and then
Remove the initial function definition, as the
= Set would evaluate the initial function at that very moment, but actually you have to wrap it in an
Evaluate if you are to do what I just suggested, but my note about the use of
:= remains true to form, as that would evaluate f upon execution of your redefined/alternative function
Will all accomplish what you desire, and all of these would carry the same required input of
g[altv3] to achieve evaluation!
Hope this helps!