/// <summary> /// Provides the surface of this function if it has been statically defined /// </summary> /// <param name="context">the context used to create the surface</param> /// <param name="xParam">The X axis of this surface</param> /// <param name="yParam">The Y axis of this surface</param> /// <param name="explain"></param> /// <returns>The surface which corresponds to this expression</returns> public override Surface CreateSurface(InterpretationContext context, Parameter xParam, Parameter yParam, ExplanationPart explain) { Surface retVal = base.CreateSurface(context, xParam, yParam, explain); Surface surface = InitialValue.CreateSurface(context, xParam, yParam, explain); if (surface != null) { ListValue value = ListExpression.GetValue(context, explain) as ListValue; if (value != null) { int token = PrepareIteration(context); AccumulatorVariable.Value = surface.Function; foreach (IValue v in value.Val) { if (v != EfsSystem.Instance.EmptyValue) { // All elements should always be != from EmptyValue ElementFound = true; IteratorVariable.Value = v; if (ConditionSatisfied(context, explain)) { MatchingElementFound = true; AccumulatorVariable.Value = IteratorExpression.GetValue(context, explain); } } NextIteration(); } Function function = AccumulatorVariable.Value as Function; if (function != null) { retVal = function.Surface; } else { throw new Exception("Expression does not reduces to a function"); } EndIteration(context, explain, token); } } else { throw new Exception("Cannot create surface for initial value " + InitialValue); } retVal.XParameter = xParam; retVal.YParameter = yParam; return(retVal); }