I'm trying to make the following, from a dynamically filled List:
val primitives = "x" | "y" | "z" // what I want
val primitives2 = List("x", "y", "z") // what I need to transform from
I figured something like this might work:
primitives2.reduce(_|_)
But no go. I then found this snippet, which works:
primitives2.foldRight(failure("no matching delimiter"): Parser[Any])(_|_)
However, the base case failure("no matching delimiter") is confusing. Is that just the equivalent Nil case for Parser objects?