I have a Spline (interpolation) type: 
    
    
    type
      Spline*[T] = ref object
        x: seq[float]
        coeffs: seq[tuple[float, float, T, T]]
    
    
    Run

And I can evaluate it at a point t using: 
    
    
    eval*[T](spline: Spline[T], t: float): T
    
    
    Run

What I would like to do, is to create a proc for a specific spline so that I 
can call it without having to supply the Spline. Something like this: 
    
    
    var spline = newSpline(x, y)
    # Current way to evaluate it:
    echo spline.eval(2.5)
    
    # How I would like it:
    var f = Spline2Proc(spline) # this is just a placeholder for the magic I 
want.
    echo f(2.5)
    
    
    Run

The reason for this is that I want to be able to pass a Spline as a proc to for 
example a proc that does numerical integration of a function.

Is this possible to do in Nim (without too much troubles)? 

Reply via email to