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)


:-)
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to