I have a simple math function that produce a saw-like pattern. The question is - How to apply a distortion effect to it? [![enter image description here][1]][1]

Here's an example of the code: 

    shader basic_function(
    point Pos = P,
    output float f = 0)

    {float x = Pos[0];
    float y = Pos[1];
    float z = Pos[2];
       
    f = (z + 0.5 - floor(z));}
    

PS
Honestly, Im a new one in osl shader writing so it possible that I dont understand what im doing. 


  [1]: https://i.sstatic.net/nAfwx.png