[Haskell-cafe] Small question about something easy
iliali16
iliali16 at gmail.com
Tue Mar 18 10:56:16 EDT 2008
Thanks to all of you I got it I was missing the notation. Thanks again!
iliali16 wrote:
>
> Hi guys I am a bit new to haskell but I am doing good till now. I have to
> write a function that takes 2 inputs and then reutns one composite output.
> Now my problem is that I have to make composition of that function meaning
> that I have to access in some way the output of the function before it is
> really computed. I will show you part of my code which is working
> prefectly:
>
> play :: Logo -> TurtleState -> (Image, TurtleState)
>
> play DoNothing (pen, (x,y), angle) = (emptyImage, (pen, (x,y), angle))
>
> play PenDown (pen, (x,y), angle) = (emptyImage,(pen, (x,y), angle))
>
> play PenUp (pen, (x,y), angle) = (emptyImage,(pen, (x,y), angle))
>
> play (Forward n) (pen, (x,y), angle)
> |pen == True = ((line (x,y) (x+n,y+n)), (True, (x+n,y+n), angle))
> |otherwise = (emptyImage,(pen, (x+n,y+n), angle))
>
> play (Turn n) (pen, (x,y), angle) = (emptyImage, (pen, (x,y), (angle+n)))
>
> play (DoNothing :>: p2) (pen, (x,y), angle) = play p2 (pen, (x,y), angle)
> play (p1 :> DoNothing) (pen, (x,y), angle) = play p1 (pen, (x,y), angle)
> play (PenDown :>: PenUp) (pen, (x,y), angle) = (emptyImage,(pen, (x,y),
> angle))
> play (PenDown :>: (Forward n)) (pen, (x,y), angle) = play (Forward n)
> (True, (x,y), angle)
> play (PenDown :>: PenDown) (pen, (x,y), angle) = (emptyImage,(pen, (x,y),
> angle))
> play (PenDown :>: (Turn n)) (pen, (x,y), angle) = play (Turn n) (pen,
> (x,y), angle)
> play (PenUp :>: PenUp) (pen, (x,y), angle) = (emptyImage,(pen, (x,y),
> angle))
> play (PenUp :>: (Forward n)) (pen, (x,y), angle) = play (Forward n)
> (False, (x,y), angle)
> play (PenUp :>: (Turn n)) (pen, (x,y), angle) = play (Turn n) (pen, (x,y),
> angle)
> play (PenUp :>: PenDown) (pen, (x,y), angle) = (emptyImage,(pen, (x,y),
> angle))
>
> Now the problem comes here:
> play (p1 :>: p2) state
> |play p1 state == (i1,state1) && play p2 state1 ==
> (i2,state2) = (i1+++i2,state2)
>
> I know that if I manage to do that function the one above with this sign
> :>: do not need to be impelmented since this one will cater for all the
> cases. Can you please help me?
>
> Thanks in advance!
>
:jumping::jumping::jumping::jumping::jumping::jumping::jumping::jumping::jumping::jumping::jumping::jumping::jumping::jumping:
--
View this message in context: http://www.nabble.com/Small-question-about-something-easy-tp16119618p16121996.html
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.
More information about the Haskell-Cafe
mailing list