On Thu, Jul 14, 2005 at 01:44:05PM +0300, Yitzchak Gale wrote:
> Here it is translated into regular monad syntax:
> 
> > coinsM _  0 k = return []
> > coinsM _  _ 0 = []
> > coinsM cs a k = do
> >   t <- init (tails cs)
> >   let h = head t
> >   unless (h <= a) []
> >   s <- coinsM t (a-h) (k-1)
> >   return (h:s)
> 
> (The function "unless" is from the Control.Monad
> module.)

[] is an instance of MonadPlus, which allows you to use "guard" instead
of "unless ...":

    guard (h <= a)

Best regards
Tomasz
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to