[racket] interaction between in-cycle and in-value
I'm trying to create a long-running for loop; and would like a
"heart beat" mechanism to show progress.
I've tried to use:
(for/sum
([i (in-range 1000000)]
[pulse (in-cycle (in-range 999) (in-value (displayln ".")))]
)
i)
Which gives me:
Value: 499999500000
stdout: ".\n"
[I think rudybot was grateful for not having to display 1000 dots; but...
with some experimentation:
[soegaard asked rudybot]:
(for ([j (in-range 10)] [i (in-cycle (in-range 3) (in-value (displayln
".")))]) (displayln i))
stdout: ".\n0\n1\n2\n#<void>\n0\n1\n2\n#<void>\n0\n1\n"
Which suggests that the in-value is evaluated once printing a dot and
returning #<void> -- then returning void (which is printed out with the
(displayln i) clause.
The documentation for in-cycle says:
"where each seq is initiated afresh in each iteration"
Can (in-value ..) not be "initiated afresh"?
Why not?
Is there a bug in the documentation of (in-cycle)?
Or should (in-value) be documented as "cannot be initiated afresh"?
Regards.
Tim
--
Tim Brown <tim.brown at cityc.co.uk> | City Computing Limited |
T: +44 20 8770 2110 | City House, Sutton Park Road |
F: +44 20 8770 2130 | Sutton, Surrey, SM1 2AE, GB |
-----------------------------------------------------------------------|
BEAUTY: What's in your eye when you have a bee in your hand |
-----------------------------------------------------------------------'
City Computing Limited registered in London No. 1767817.
Registered Office: City House, Sutton Park Road, Sutton, Surrey, SM1 2AE
VAT number 372 8290 34.