On 21 February 2017 at 13:08, Paul Moore <[email protected]> wrote:
> I guess I'd want an 2d array of value : count entries and each time
> through the loop increment the appropriate row. I think I probably
> need some variation on { and }, but the examples I've found in the
> documentation are way to dense for me to work out how simple uses
> would work :-(

Hmm. Did some more digging. If I had a dense array of counts, I'd do

    array val} >: val { array

(Get element val, increment it, and return a new array with item val
replaced by the incremented value).

   (0 0 0 0 0) 3}>:3{ 0 0 0 0 0
|index error
| (0 0 0 0 0) 3}>:3{0 0 0 0 0

Hmm... I was expecting 0 0 0 1 0.

If I could get that working, that would be a start. Making it an
association (so I can have results that aren't necessarily in a fixed
range 0...n) would be the next step.

Paul
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to