Ejemplo n.º 1
0
        /// <summary>
        /// Returns as sequence that will yield all values to and including <paramref name="guard"/>
        /// </summary>
        public static IEnumerable <int> Through(this IterationSpecification me, int guard)
        {
            var current = me.StartValue;

            if (me.StepSize > 0)
            {
                while (current <= guard)
                {
                    yield return(current);

                    current += me.StepSize;
                }
            }
            else
            {
                while (current >= guard)
                {
                    yield return(current);

                    current += me.StepSize;
                }
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Returns as sequence that will yield all values to but excluding <paramref name="guard"/>
 /// </summary>
 public static IEnumerable <int> Until(this IterationSpecification me, int guard)
 {
     return(me.Through(guard - Math.Sign(me.StepSize)));
 }