How to abort evaluation of a sequence of inputs?

前端 未结 3 998
北海茫月
北海茫月 2020-12-10 19:57

By default pressing Alt+. or calling Abort[] within the evaluation causes abort of the currently evaluating input. But when working in the

3条回答
  •  臣服心动
    2020-12-10 20:35

    Sasha's suggestion to just use four cells is valid, because that's basically what the FrontEnd does anyway, submitting several distinct evaluations to the Kernel. If you insist in using one cell, wrap it in parens (CompoundExpression), which causes those four lines to be treated as one evaluation (note the need for ; too):

    (
       f := CheckAbort[Pause[.1], Abort[]];
       While[True, f];
       While[True, f];
       While[True, f]
    )
    

    Then, one abort issued will abort the evaluation as a whole.

提交回复
热议问题