Skip to content

(Idea) LINQ methods #153

@AdamSpeight2008

Description

@AdamSpeight2008

LINQ extension methods that also return the Enumerator, so that the rest of the sequence can further processed. I think that the enumerator be required to be lifted into a capture so it lifetime can persist across multiple methods.
Example: OnFirst

Tuple<IEnumerator<T>,R> OnFirst<T,R>( this IEnumerable<T> xs , initial R, Func<R,T, R> fn )
{
  var en = xs.GetEnumerator();
  var res = initial;
  if( en.MoveNext() ) 
  {
    res = fn(res, en.Current )
    return Tuple.Create(res, en );
  }
  return res;
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions