Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3359850
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T02:55:22+00:00 2026-05-18T02:55:22+00:00

Does anyone else feel that the iterators are coming up short when you want

  • 0

Does anyone else feel that the iterators are coming up short when you want to take a part a sequence piece by piece?

Maybe I should just start writing my code in F# (btw anybody knows if F# uses lazy evaluation) but I’ve found myself wanting a way to pull at a sequence in a very distinct way.

e.g.

// string.Split implemented as a generator, with lazy evaluation
var it = "a,b,c".GetSplit(',').GetEnumerator();
it.MoveNext();
var a = it.Current;
it.MoveNext();
it.MoveNext();
var c = it.Current;

That works, but I don’t like it, it is ugly. So can I do this?

var it = "a,b,c".GetSplit(',');
string a;
var c = it.Yield(out a).Skip(1).First();

That’s better. But I’m wondering if there’s another way of generalizing the same semantic, maybe this is good enough. Usually I’m doing some embedded string parsing, that’s when this pops out.

There’s also the case where I wish to consume a sequence up to a specific point, then basically, fork it (or clone it, that’s better). Like so

var s = "abc";
IEnumerable<string> a;
var b = s.Skip(1).Fork(out a);
var s2 = new string(a.ToArray()); // "bc"
var s3 = new string(b.ToArray()); // "bc"

This last one, might not be that useful at first, I find that it solves backtracking issues rather conveniently.

My question is do we need this? or does it already exist in some manner and I’ve just missed it?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T02:55:22+00:00Added an answer on May 18, 2026 at 2:55 am

    Sequences basically work OK at what they do, which is to provide a simple interface that yields a stream of values on demand. If you have more complicated demands then you’re welcome to use a more powerful interface.

    For instance, your string examples look like they could benefit being written as a parser: that is, a function that consumes a sequence of characters from a stream and uses internal state to keep track of where it is in the stream.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.