[Haskell-cafe] [Parsec] A combinator to match between M and N
times?
Henning Thielemann
lemming at henning-thielemann.de
Tue Aug 29 09:31:30 EDT 2006
On Tue, 29 Aug 2006, Tomasz Zielonka wrote:
> How about this?
>
> countBetween m n p = do
> xs <- count m p
> ys <- count (n - m) $ option Nothing $ do
> y <- p
> return (Just y)
> return (xs ++ catMaybes ys)
>
> Assuming n >= m.
>
> > Does anyone has a solution? Preferrably one I can understand, which
> > means not yet with liftM :-)
>
> No liftM, as requested :-)
Although, one is tempted to write
liftM Just p
instead of
do
y <- p
return (Just y)
:-)
More information about the Haskell-Cafe
mailing list