[ prog / sol / mona ]

prog


LISP Puzzles

49 2020-04-17 02:51

The interplay of 'test' and 'generate' in the C++ version >>45 confused me for a moment. It becomes much clearer if 'generate' is renamed to 'advance' and 'test' to 'needs_jump'. It would be even better if 'test' did not have two responsibilities. The technique used is almost the same stack of generators as in >>36, but with a variation. In >>36 generator k only resorts to generator k+1 when this is needed. But in >>45 the call to 'test' is always made, and it both returns whether a jump is needed at level k, and advances level k+1 if a check determines this is needed. The generator at level k does not possess enough information to avoid the need for the 'while' check in 'test' on every single invocation, even though this is avoidable. The same extra information would also prevent the need for most 'test' calls. Currently, other than the code golfed increment inside the argument list, the overwhelming majority of 'test' calls are useless no-ops, hence the inline request. In >>36 this extra information is available so the call pattern is much more disciplined. From a design perspective, the C++ version sends out notifications all the time and the recipient decides whether they were needed, but in my version notifications are only sent out when it is known that they are needed.

Site was down, so posted on lain.

157


VIP:

do not edit these