GUI implementation with Racket I am studying the book Realm of Racket.

On chapter 5, there is a challenge:

Find an image of a locomotive. Create an animation that runs the locomotive
from just past the left margin to just past the right margin of the screen. Next, modify your program so the locomotive wraps around to the left side of the screen after passing the right margin.

I created the following code using Racket and Dr. Racket.

However, I bet it could be improved. 

My doubt is specially about the transition from the right side to the left side. I think there should be a better way of doing this:

#lang racket

(require 2htdp/universe 2htdp/image)   

(define LOCOMOTIVE image-inserted-through-DrRacket )

(define HEIGHT 800)

(define WIDTH 800)

;essa função muda a velocidade com que a figura se mexe

(define (add-3-to-state current-state)
  (if (&lt; current-state 1055)
      (+ current-state 6)
      (- current-state 800)))

(define (locomotive-running current-state)
  (place-image LOCOMOTIVE current-state (/ WIDTH 2)
               (empty-scene WIDTH HEIGHT)))

(big-bang 0
          (on-tick add-3-to-state)
          (to-draw locomotive-running))


That's the image that I used:
Broadly speaking, I'd say it looks pretty good. I'm a bit confused by the '1055'; I'm guessing that you're trying to wait until the train leaves the screen entirely? Perhaps you could write this as

(+ WIDTH (/ (image-width LOCOMOTIVE) 2))


... and also replace the 800 with WIDTH. Alternatively, you could return either 0 or 

(- (/ (image-width LOCOMOTIVE) 2))


when the train goes off the right edge, so that it makes its entrance smoothly.