Where is the parse error in this program?


397
views
0
6 months ago by

 

data World = World (Marble, Ball, Flag)
data Marble = Marble(Number, Number, Number, Number)
data Ball = Ball (Number, Number, Number, Number)
data Flag = Flag (Number, Number)
data FlagF = FlagF (Number, Number)

main = simulationOf(initial, step, picture)

initial(rs) = World (initialMarble,initialBall,initialFlag)
initialMarble = Marble(-8,8,3,-1)
initialBall = Ball (11,4,3,5)
initialFlag = Flag (7,-7)
initialFlagF = FlagF (6,-7)


step(world,dt)= gravity(world,dt)

gravity(x,y,xv,yv)
|x > 4 = (x,y)
|y < 7 = (x,y)
|xv > 6 = (xv, yv)
|yv < 5 = (xv, yv)
|otherwise = (x,y,xv,yv)

picture = (World(m,b,f,ff)&marble(m)&ball(b)&flag(f)&flagF(ff)

marble(m) = colored(translated(solidCircle(1),-8,8),red) <------ Parse Error
ball(b) = colored(translated(solidCircle(1), 11,4),cyan)
flag(f) = colored(translated(solidRectangle(1,5),gray),7,-7)
flagF(ff) = colored(translated(solidRectangle(1,4),green),6,-7)

link wont work srry

Community: CodeWorld

1 Answer


0
6 months ago by

The problem is on the previous line.  That's normal for parse errors, because most of the time, the computer doesn't realize there's anything wrong until it gets to the next line.

In the definition of picture, I think you wanted something like this:

picture(World(m, b, f, ff)) = marble(m) & ball(b) & flag(f) & flagF(ff)

Thank You Chris. From: Aaron and Alyssa (we're working together)

written 6 months ago by Alyssa Ann Dilan  
Please login to add an answer/comment or follow this question.

Similar posts:
Search »
  • Nothing matches yet.