fork download
  1. #lang racket
  2.  
  3. (require plot (only-in srfi/41 stream-map))
  4. (plot-new-window? #t)
  5.  
  6. (define-values (*m* *k* *dt*) (values 1 10 0.01))
  7.  
  8. (define *v*
  9. (stream-cons 0
  10. (stream-map (lambda (v x)
  11. (- v (* (/ *k* *m*) x *dt*))) *v* *x*)))
  12.  
  13. (define *x*
  14. (stream-cons 1
  15. (stream-map (lambda (x v)
  16. (+ x (* v *dt*))) *x* (stream-rest *v*))))
  17.  
  18. (define *xs* (stream->list (stream-take *x* 500)))
  19. (define *ts* (map (lambda (x) (* x *dt*)) (range 500)))
  20. (plot (lines (map vector *ts* *xs*))
  21. #:x-label "t" #:y-label "x" #:title "t-x")
Runtime error #stdin #stdout #stderr 2.51s 203420KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
prog.rkt:18:28: stream-take: unbound identifier
  in: stream-take
  location...:
   prog.rkt:18:28
  context...:
   raise-unbound-syntax-error
   for-loop
   loop
   [repeats 8 more times]
   module-begin-k
   expand-module16
   expand-capturing-lifts
   expand-single
   temp74_0
   compile16
   temp68_2
   loop