ACross

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

ACross

Jenny678
Hello,

Can somebody help me
My Problem is to define a code for:

>cross 7         -- means 7*7
>+++++++
>++      ++
>+  +  +  +
>+    +    +
>+  +  +  +
>++      ++
>+++++++

Another Example
>cross 13                   -- 13*13          
>+++++++++++++
>++                  ++
>+  +              +  +
>+    +          +    +
>+      +      +      +
>+        +  +        +
>+          +          +
>+        +  +        +
>+      +      +      +
>+    +          +    +
>+  +              +  +
>++                  ++
>+++++++++++++

Can I use putString ???
Thanks for any help      
Reply | Threaded
Open this post in threaded view
|

Re: ACross

Stefan Holdermans
Hi all,

> Can somebody help me
> My Problem is to define a code for:
>
>> cross 7         -- means 7*7
>> +++++++
>> ++      ++
>> +  +  +  +
>> +    +    +
>> +  +  +  +
>> ++      ++
>> +++++++

Not to be the bad guy, but perhaps it's a good idea to remind  
ourselves of our homework policy.

Regards,

   Stefan
_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: ACross

Jared Updike
> Not to be the bad guy, but perhaps it's a good idea to remind
> ourselves of our homework policy.

This?

  http://www.haskell.org/hawiki/HomeworkHelp

> Can I use putString ???

If you mean putStrLn and putStr, then yes. I would first make a
function that constructs the string or list of strings (maybe using
++) you need to display, and then call putStr and/or putStrLn the
appropriate number of times.

Other questions to answer:

* Can we safely ignore the case of even numbers?, i.e. cross 2, cross
4, cross 6, etc.
* Looking at the output lines, how can we break down or classify them,
in terms of numbers of plus signs and areas of spaces? Which lines are
similar? etc.

Good luck,
  Jared.
--
http://www.updike.org/~jared/
reverse ")-:"
_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: ACross

Vo Minh Thu
2006/6/19, Jared Updike <[hidden email]>:
[...]
> * Looking at the output lines, how can we break down or classify them,
> in terms of numbers of plus signs and areas of spaces? Which lines are
> similar? etc.

in other words, given 'cross n', what's the relationship between the
number of line to produce and 'n' ? and what's the relationship
between line number i and 'n' ?

bye,
vo minh thu
_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: ACross

Udo Stenzel
In reply to this post by Jenny678
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

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

signature.asc (196 bytes) Download Attachment