GLSL Reusable Custom Function to CG

Please advise how to translate the GLSL code below into CG. I want to reuse this function multiple times in one shader:

float remap(float value, float low1, float high1, float low2, float high2){
    return(low2 + (high2 - low2) * (value - low1) / (high1 - low1));
}

Alright I realized this cannot be in the fragment shader function but needs to go before it. Working for me now.