[plt-scheme] on-tick in 2htdp/universe.ss

From: Mitchell Wand (wand at ccs.neu.edu)
Date: Sat Apr 4 11:14:35 EDT 2009

What is the correct contract for an on-tick handler in the universe

I'm playing with the universe teachpack, and I'm having trouble writing an
on-tick clause for a universe.

The help files says clearly:

(on-tick tick-expr)
   tick-expr : (-> [listof world?] UniverseState bundle?)

The one example I could find of a universe with an on-tick handler (in
universe.ss) says

 (universe '()
            (on-new nu)
            (on-msg process)
            (on-tick (lambda (u x) (printf "hello!\n") (list u)) 1)))

This clearly supplies a function of 2 arguments, though not one that
apparently matches the contract
in the help file.

But when I try to say

(define (on-tick-fn worlds s-state)
  (make-bundle worlds s-state empty))

(define (run-server d)
   (on-new on-new-fn)
   (on-msg on-msg-fn)
   (on-tick on-tick-fn 1)

I get:

> (run-server 1)
on-tick: procedure of one argument expected as first argument; given
procedure of 2 arguments

What's up with this?  What values are actually sent to the on-tick handler?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20090404/dae824af/attachment.html>

Posted on the users mailing list.