[EMAIL PROTECTED] (Marcin 'Qrczak' Kowalczyk) wrote,
> Mon, 9 Apr 2001 14:30:01 +1000, Fergus Henderson <[EMAIL PROTECTED]> pisze:
>
> > For an example of this, I've attached a program for solving the
> > 8-queens problem;
>
> Here is mine, also using the list monad together with the state monad
> (uses StateT [] and not ListT State, so the state is restored during
> backtracking and not permanent).
>
> import Monad;import MonadState;main=mapM_(\s->mapM_ putStrLn$[]:[take
> 8$replicate i '.'++'Q':repeat '.'|i<-s])$evalStateT(mapM(\i->msum[do
> (/)<-get;guard$i/j;put(\x y->y/=j&&x+y/=i+j&&x-y/=i-j&&x/y);return j
> |j<-a])a)(\_ _->True);a=[0..7]
I always knew that inside Haskell there is a Perl trying to
get out!
Manuel
_______________________________________________
Haskell-Cafe mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell-cafe