i. on open (unboxed) arrays can only find entire rows, not parts of a row.
On Sat, Oct 26, 2013 at 6:49 PM, Pascal Jasmin <[email protected]>wrote: > In this structure, > > 'aa',~'asdf',:'asd' > > how would you recommend finding the row (or first row) with 'aa ' in it, > knowing only that 'aa' is what you are searching for? > > > This works: > 'aa' I~ 'aa',~'asdf',:'asd' > 2 > > I guess that is what its for :) > > some timings though: > > a =. (<'aa') ,~ (? 1e5 $ 26) <@:$"0 1 (65+i.26) { a. NB. boxed > > > 10 ts '(<''ABC'') i.~ a' > > 312499/sec 0.002304MB > 10 ts '(<''ABD'') i.~ a' NB. not found > 243.847/sec 0.002304MB > 10 ts '(<''aa'') i.~ a' NB. last to find > 206.336/sec 0.002304MB > 10 ts '(<''ABC'') i:~ a' > 416666/sec 0.002304MB > > a2 =. 'aa' ,~ (? 1e5 $ 26) $"0 1 (65+i.26) { a. NB. padded strings unboxed > > > 10 ts '(''ABC'') I~ a2' > 99.3004/sec 6.29952MB > 10 ts '(''ABD'') I~ a2' > 99.7279/sec 6.29952MB > 10 ts '(''aa'') I~ a2' > 101.727/sec 6.29952MB > > > > ________________________________ > From: Roger Hui <[email protected]> > To: Programming forum <[email protected]> > Sent: Wednesday, October 23, 2013 4:28:52 PM > Subject: Re: [Jprogramming] a more useful i. ? > > > It is much more efficient in time and space to eschew boxing within a > column. > > > > On Wed, Oct 23, 2013 at 2:23 PM, Pascal Jasmin <[email protected] > >wrote: > > > I find that using boxed strings in inverted tables avoids a whole series > > of issues that occur if you let J fill short strings with pads until they > > match length to whatever the longest string is. > > > > I don't really know how much it slows down things by doing it that way, > > but the approach can fix i. by comparing to boxed values. I definitely > > don't have an exhaustive list of things that seem harder without boxing > > first, but there is probably more than just i. > > > > > > ________________________________ > > From: Roger Hui <[email protected]> > > To: Programming forum <[email protected]> > > Sent: Wednesday, October 23, 2013 4:53:34 PM > > Subject: Re: [Jprogramming] a more useful i. ? > > > > > > Thanks. I had not intended to promote rank-deficient arguments. I > > probably want to disallow that. > > > > One effect would be to make > > http://www.jsoftware.com/jwiki/Essays/Inverted_Table#Index_of more > > immediately useful: If you have to do the overtake yourself for one > table, > > it's tolerable; if you have to do it on some subset of columns (and you > > don't know ahead of time which ones), it's a big mess. Basically in > > > > tindexof=: i.&>~@[ i.&|: i.&> > > > > you'd replace the i. in the left and right tines with the I verb that I > > defined. > > > > > > > > > > On Wed, Oct 23, 2013 at 1:45 PM, Henry Rich <[email protected]> > wrote: > > > > > Seems reasonable. This would also promote atoms to match rows of > tables. > > > I've never needed it. > > > > > > Henry Rich > > > > > > > > > On 10/23/2013 4:28 PM, Roger Hui wrote: > > > > > >> Thought experiment: What if i. does overtake on the arguments to > ensure > > >> that the item shape of the left argument matches the cell shape of the > > >> right argument? > > >> > > >> I=: 4 : '(s{."c x) i. (s{."c y) [ s=. (}.$x)>.(-c=. <:$$x){.$y' > > >> x=: > ;:'zero one two five one' > > >> y=: > ;:'three one four one five nine' > > >> > > >> $x > > >> 5 4 > > >> $y > > >> 6 5 > > >> > > >> x i. y > > >> 5 5 5 5 5 5 > > >> x I y > > >> 5 1 5 1 3 5 > > >> ------------------------------**------------------------------** > > >> ---------- > > >> For information about J forums see > > http://www.jsoftware.com/**forums.htm< > http://www.jsoftware.com/forums.htm> > > > > > >> > > >> ------------------------------**------------------------------** > > > ---------- > > > For information about J forums see > http://www.jsoftware.com/**forums.htm > > <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 > > > ---------------------------------------------------------------------- > 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
