Animate (the Racket function)

110 views
Skip to first unread message

patr...@frenchamericansf.org

unread,
Aug 23, 2016, 4:15:00 PM8/23/16
to Bootstrap-Teachers
I recently watch Matthias Felleisen's talk from Strange Loop 2015. I really liked the early example he used about animating the cart when doing word problems (A cart is traveling down the road at 10 mph. After 3 hours, how far has the cart traveled?). So I thought I would create something similar on WeScheme. Everything works as I expected, except for one thing. Matthias showed off the function "animate" which, I assume, is a quick way of making a big-bang (if I'm wrong, I'd love to know what it does). "Animate" would work when my "render" function had one variable. However, I decided to have the user input the speed and time when calling the "render". Now "animate" generates an error message. Is that because "render" has two variables? Is there a way to animate the cart when "render" has two variables? Here's a copy of the code for some context: http://www.wescheme.org/view?publicId=ocG3wQlGv1

Schanzer (Director)

unread,
Aug 23, 2016, 4:36:34 PM8/23/16
to Bootstrap-Teachers
Unfortunately, your code will not work in DrRacket or WeScheme. 

animate consumes a function that take takes only one argument. DrRacket throws a much nicer error: run-simulation: expected function of one argument as first argument; given function of 2 arguments 

I'll try to get a better error message up on WeScheme by next week.

patr...@frenchamericansf.org

unread,
Aug 23, 2016, 4:40:42 PM8/23/16
to Bootstrap-Teachers
If I write (render 2 15) that will calculate how far the cart has traveled after two hours when traveling 15 kmh. Does that not work for you?

Schanzer (Director)

unread,
Aug 23, 2016, 4:45:44 PM8/23/16
to Bootstrap-Teachers
(render 2 15) works just fine on it's own. But if you want to use render with animate, you're going to have to fix it so that it only consumes a single argument. 
Reply all
Reply to author
Forward
0 new messages