I am doing

tbl = {};
 Do[AppendTo[tbl, RandomInteger[{1, 100000}, 2]], 100000],

(well in fact I am doing something less boring but what I want to ask about happens here too)

Every now and then the following message is generated:

RandomInteger::array: The array dimensions 2 given in position 2 of
RandomInteger[{1,100000},2] should be a list of non-negative machine-sized integers
giving the dimensions for the result.

What is wrong?

  • 3
    $\begingroup$ Now such message when I execute it in version 11.3 on macOS. Try to restart the kernel. Btw., this use of AppendTo slows down things needlessly: A randomm table of that size can be obtained with RandomInteger[{1, 100000}, {100000, 2}]; in a 20000th part of the time. $\endgroup$ Aug 6, 2018 at 12:52
  • $\begingroup$ @HenrikSchumacher Mine is 11.0.1 on Windows 10. The reason I use AppendTo is that what I actually want to do requires some time at each step, so I would like to place a ListPlot as the second argument of Monitor, to watch the picture while it gradually emerges. $\endgroup$ Aug 6, 2018 at 13:10
  • 1
    $\begingroup$ Run the code 5 times on a fresh kernel, and no error message. Tested on 10.4.1 for Microsoft Windows (64-bit). $\endgroup$ Aug 6, 2018 at 15:11
  • $\begingroup$ Error Do::itform in MMAv9. $\endgroup$
    – Hector
    Aug 6, 2018 at 18:17
  • 2
    $\begingroup$ It was a perfectly good question (albeit with imperfect info). The key was use of Monitor, which interacts with the kernel using a thread. THere was a bug, now fixed, in (mis)handling of a signal that hits at an inopportune time; there was cross-talk between threads and the Do iterator was getting messed up. If you provide full code to replicate we can try testing in a current kernel to make sure we fully made it go splat (the bug, I mean, not your code). Can do this either in this MSE question or through Tech Support. $\endgroup$ Oct 18, 2018 at 21:51


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.