On Wed, Aug 14, 2019 at 10:39 AM Henry Rich <[email protected]> wrote: > Program spec: given 2 lists x and y, find the index of the largest value > in y, and increment the corresponding value in x. Result is the new x. > Example: given x=1 2 3 and y=4 2 3, result is 2 2 3.
... > You could keep going till you get a full tacit program, but I would stop > here. Actually, increment can be achieved using addition: 1 2 3 (+ (= >./))4 2 3 2 2 3 Now, ok... that might not be what you intended. The spec doesn't say what to do if there's an array of indices of the largest value whose length is greater than 1. That said, there's a recipe for "zeroing all but the first 1 in a bit vector": </\ 0 1 0 1 0 1 0 1 0 0 0 0 So, you could also go: 1 2 3 4 (+ </\@(= >./))4 2 3 4 2 2 3 4 But... in a sense, this messes up your presentation, so also allow me to emphasize what was important about it: (1) Getting a working implementation is critical. You should not hesitate to write an explicit routine if you are stalled writing a tacit routine. (2) It's often wise to continue your development effort after you have your initial working draft. The working draft can help you test alternatives, but also additional time spent increases your ability to spot problems (bugs, oversights, needed documentation, etc.) ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
