Another option to consider:
Treat the problem as a `reduce` on the sequence of adjustments where the
processing of each adjustment depends on the user input and "cancel" makes the
processing return (reduced nil) to halt the reduction. That will stop
automatically when the sequence of adjustment
How about:
(doseq [i [1 2 3 4] :while (< i 3)]
(println i))
Alternatively, if you need some outside state you can:
(let [stop-i (atom 3)]
(doseq [i [1 2 3 4] :while (< i @stop-i)]
(println i)))
Rangel
@raspasov
On Sunday, March 1, 2015 at 2:30:22 AM UTC-8, Cecil Westerhof wrote
How about:
(doseq [i [1 2 3 4] :while (< i 3)]
(println i))
Alternatively, if you need some outside state you can:
(let [stop-i (volatile! 3)]
(doseq [i [1 2 3 4] :while (< i @stop-i)]
(println i)))
Rangel
@raspasov
On Sunday, March 1, 2015 at 2:30:22 AM UTC-8, Cecil Westerhof w
A really good tip I read somewhere was that before you write *any* of your
own code check the core API and libs - it is almost certainly there.
https://jafingerhut.github.io/cheatsheet/grimoire/cheatsheet-tiptip-cdocs-summary.html,
clojuredocs.org and http://www.clojure-toolbox.com are invaluab
I know what you mean. After a year or so I still oscillate between a day of:
- naval gazing to uncover a lovely clean design, a few trivial bits
of clojure later and out comes a lovely, incidental-complexity free
implementation that reads like a conversation from the domain actors
in the real worl
2015-03-01 11:33 GMT+01:00 Colin Yates :
> I would replace it with loop/recur or a while, with both checking a
> termination flag (probably an atom) which is set by the user.
>
I was just going to post that I was going to use a loop. You beat me to
it. ;-)
Probably being busy for to long, because
I would replace it with loop/recur or a while, with both checking a
termination flag (probably an atom) which is set by the user.
An alternative approach would be core.async with a stop channel and then
use alt! to check them both simultaneously.
On 1 Mar 2015 10:30, "Cecil Westerhof" wrote:
> I
I have a program where I change a lot of records based on id's in a
sequence. It is a manual process, so I want to give the user an option to
terminate the sequence. What would be the correct way to stop (for example)
a doseq?
--
Cecil Westerhof
--
You received this message because you are subs