Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there a good way to turn Digit.Repeat(n) into a string? #137

Closed
atrauzzi opened this issue Nov 15, 2022 · 2 comments
Closed

Is there a good way to turn Digit.Repeat(n) into a string? #137

atrauzzi opened this issue Nov 15, 2022 · 2 comments
Labels

Comments

@atrauzzi
Copy link

Right now it seems to return IEnumerable<char>, which is obviously a precursor to a string. I was wondering if Pidgin had any handy way of doing this, versus me just manually making the string in a Map somewhere later on?

@benjamin-hodgson
Copy link
Owner

Does this do what you meant?

static Parser<TToken, string> RepeatString<TToken>(this Parser<TToken, char> p, int n)
    => p.Repeat(n).Select(string.Concat);

@atrauzzi
Copy link
Author

It's cleaner, yes 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants