[Haskell-cafe] ACross
Udo Stenzel
u.stenzel at web.de
Tue Jun 20 06:51:20 EDT 2006
Jenny678 wrote:
> Can somebody help me
> My Problem is to define a code for:
>
> >cross 7 -- means 7*7
> >+++++++
> >++ ++
> >+ + + +
> >+ + +
> >+ + + +
> >++ ++
> >+++++++
As always, try to decompose a hard problem into simple steps. It's
probably adequate to represent pictures as
*> type Picture = [String]
then compose your "cross" from six lines. An overlay operator
*> over :: Picture -> Picture -> Picture
is trivial to write. Creating the lines should be easy,
*> replicate :: Int -> a -> [a]
from the Prelude and list comprehensions might help.
> Can I use putString ???
Of course, but you shouldn't. Creating a cross is a seperate step from
putting it on screen. "cross" should probably return a list of Strings
or a single String (think "unlines"). In fact,
*> cross :: Int -> Picture
definitely makes the most sense to me.
Udo.
--
People with great minds talk about ideas.
People with ordinary minds talk about things.
People with small minds talk about other people.
-- Eleanor Roosevelt
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://www.haskell.org//pipermail/haskell-cafe/attachments/20060620/832a5ca0/attachment.bin
More information about the Haskell-Cafe
mailing list