Пример #1
0
 /// <summary>
 /// A query that generates a sequence by mimicking a for loop.
 /// </summary>
 /// <typeparam name="TState">State type.</typeparam>
 /// <typeparam name="TResult">Result sequence element type.</typeparam>
 /// <param name="initialState">Initial state of the generator loop.</param>
 /// <param name="condition">Loop condition.</param>
 /// <param name="iterate">State update function to run after every iteration of the generator loop.</param>
 /// <param name="resultSelector">Result selector to compute resulting sequence elements.</param>
 /// <returns>A query whose elements are obtained by running the generator loop, yielding computed elements.</returns>
 public static IQueryExpr <IEnumerable <TResult> > Generate <TState, TResult>(TState initialState, Expression <Func <TState, bool> > condition, Expression <Func <TState, TState> > iterate, Expression <Func <TState, TResult> > resultSelector)
 {
     return(new QueryExpr <IEnumerable <TResult> >(QExpr.NewGenerate(Expression.Constant(initialState), condition, iterate, resultSelector)));
 }