private delegate double F (double x);
private delegate double[] Func (double[] xs);

private Func wrap_f (F f)
{
    Func g = (xs) => {
        var z = f (xs[0]);
        double[] ret = { z };
        return ret;
    };

    return g;
}

private double[] marshal_f (F f, double[] xs)
{
    var z = f (xs[0]);
        double[] ret = { z };
        return ret;
}

int main (string[] args)
{
    double[] xs = { 1, 2, 3 };
    assert (marshal_f ((x) => { return x * x; }, xs).length == 1);
    assert (wrap_f((x) => { return x * x; })(xs).length == 1);
    return 0;
}
