For the testing program provided by Matthew, we can also use *(timeline v)*
(an enhanced version of displayln) to compare the value of v at each
iteration and see the results in a better way:


​If you want to try it out yourself, you can go to
https://github.com/lixiangqi/medic and install the Medic package which has
support for timeline. By writing the following Medic program,

#lang medic

(layer layer1
       (in #:module "src.rkt"
           [(at (+ v (/ x 100))) [on-entry (timeline v)]]
           [(at  (+ v (/ x (- 100 x)))) [on-entry (timeline v)]]))

you'll see a timeline view of results.

Xiangqi

On Sat, Jan 24, 2015 at 09:56 AM, Matthew Flatt <mfl...@cs.utah.edu> wrote:

>
> Jens Axel and Alexander have provided the answer, but in case it helps
> to see what they mean, try these loops that display the intermediate
> results:
>
>  (for/fold ([v 0]) ([x (in-range 100)])
>    (displayln v)
>    (+ v (/ x 100)))
>
>  (for/fold ([v 0]) ([x (in-range 100)])
>    (displayln v)
>    (+ v (/ x (- 100 x))))
>
>
____________________
  Racket Users list:
  http://lists.racket-lang.org/users

Reply via email to