I have a kv library, I published before. It includes (kvinsert) an ordered 
insert function to permit arbitrary order, but its design and testing may need 
improvement.  In this case, it seems that appending then sorting represents the 
order that you want.  In kv library append also updates when searching by key 
(last key added is "the key")
  (3 5 ,. 11 12) /:~@:,~ 1 2 4 6 7 ,. 4 6 3 8 5


1 4

2 6

3 11

4 3

5 12

6 8

7 5



    On Monday, July 24, 2023 at 06:06:00 a.m. EDT, 'Mike Day' via Programming 
<programm...@jsoftware.com> wrote:  
 
 Elijah's reply offers lots of ideas, with thoughts about filling histogram 
results.
However, this might also be of interest:

  xs  NB. a small example
1 2 4 6 7
4 6 3 8 5
  expand NB. I think this is included in J at startup
#^:_1
  expxs =: {{ix,:y expand~x e.~ix=. >:i. {:x}}/
  expxs xs
1 2 3 4 5 6 7
4 6 0 3 0 8 5

This follows your apparent requirement to use origin 1. It would need refining 
if you 
wished the expanded x to start with  {.x rather than 1 .

Cheers,

Mike

Sent from my iPad

> On 24 Jul 2023, at 03:03, Fr. Daniel Gregoire <daniel.l.grego...@gmail.com> 
> wrote:
> 
> Hi!
> 
> (Apologies if this is a double-post, I believe I sent it before I was
> officially on the mailing list, and I don't see it in the archives).
> 
> Given:
> 
> |:xs
> 
> 1  23
> 2    4
> 3    5
> 4  10
> 5  397
> 6    3
> 7  190
> 8  44
> 9    4
> 10    5
> 11  13
> 12 1011
> 13  10
> 14 1119
> 15  72
> 16    1
> 17    1
> 19    6
> 21    3
> 22    2
> 23    1
> 26    2
> 28    2
> 29    2
> 30    1
> 31    2
> 
> 
> I'd like $xs to be 2 31 but you can see that 18, 20, 24, 25, and 27
> are "missing".
> 
> 
> I'd like to "fill the holes" so the first row of xs is all the
> integers 1 through 31 sequentially, and to put corresponding zeros in
> the second row where I've filled the holes in the first.
> 
> 
> My thoughts have centered around using (1+i.31),.31#0 to have a 2 by
> 31 array with all zeros in the second row, and then shifting my
> original to find the non-sequential parts with something like:
> 
> 
> (1|.{.xs) - {.xs
> 
> 
> But then I'm struggling to reason about a non-loopy way to put it all
> together. Any help is greatly appreciated.
> 
> 
> Kind regards,
> 
> Daniel
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
  
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to