public override IResultValue Evaluate() { IResultValue list = List.Evaluate(); IResultValue index = Index.Evaluate(); if (index.Type != MathType.Integer) { throw new EvaluationException(this, "Ordinal index must be integer."); } if (list.Type != MathType.List) { throw new EvaluationException(this, "Ordinal access can only be used on a list."); } return(new ResultNumberReal(list.ToList()[(int)index.ToInteger()])); }