OneOrMore parser #103
randomeizer
started this conversation in
Show and tell
Replies: 1 comment
-
Another option is to use var input = "1,2,3,4,5"[...]
let oneOrMoreNumbers = Many {
Int.parser()
} separator: {
","
}
.compactMap(NonEmpty.init)
oneOrMoreNumbers.parse(&input) // => [1, 2, 3, 4, 5] |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Not really a pitch for inclusion in the library, since it would require adding
NonEmpty
as a dependency, but I've been usingNonEmpty
in my data structures, and parsing them was a bit of a pain, so I added aOneOrMore
parser. Not quite as flexible asMany
in the library, it does the job for me, thought I'd share it:Beta Was this translation helpful? Give feedback.
All reactions