public object Invoke(IContext context, object @this, object[] arguments)
{
ArrayObject array = (ArrayObject)@this;
if (arguments != null && arguments.Length == 1)
{
int from = (int)arguments[0];
if (from < 0)
return new ArrayObject(array.Function, array.Elements.Skip(array.Elements.Count + from));
return new ArrayObject(array.Function, array.Elements.Skip(from));
}
if (arguments != null && arguments.Length == 2)
{
int from = (int)arguments[0];
int to = (int)arguments[1];
if (to < 0)
to = array.Elements.Count + to;
return new ArrayObject(array.Function, array.Elements.Skip(from).Take(to - from));
}
return new ArrayObject(array.Function, array.Elements);
}