Roger Hui wrote: >> I agree with the general point. Project Euler has a number of big >> depth-first searches which I do not know how to program >> efficiently in J. > > Is the following "efficient" according to your criteria?
<dfs_queens deleted> This is efficient. I think the problems may come on scaling up. The example given requires about 200,000 iterations through the main loop with a maximum stack size of 120. In my experience these are the main parameters affecting things. Please note that my ignorance is probably the major factor in writing efficient programs. For Project Euler #216 I will shortly have a separate query about preventing integers from being promoted. I can write the stack-oriented program illustrated, but I find some of it surprising. I always make my stacks go the other way, with pushes and pops at the end of the array. My rationale is that push then can be implemented by append in place, and for pop there is no curtail in place, but if I do them at the beginning, the stack gets copied every time. Is this true? Best wishes, John ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
