> On Behalf Of Pascal Jasmin > > ts 'i.~ lb ?. 1 + 10000 $ 10' > 0.57129244079904007 528064 > ts 'i.~ ListBlocK ?. 1 + 10000 $ 10' > 0.71161195068088268 340160 > > The performance is comparable. Which is a testament > to how well J can deal with wordy code. Your version > is very neat, and given that the adverb form is all > that is needed for the same power as the full > conjunction form (u Listblock v is equivalent to v/ u > lb). So I guess your version is better, but I can't
It seems that the equivalence is not exact. However, < @: (-.@:i.) lb 1 3 2 4 3 1 1 2 NB. Raw list of subsequent duplicates +-------------+-----------+---------+-------+-----+---+-+ |0 0 0 0 1 1 0|0 0 1 0 0 0|0 0 0 0 1|0 0 0 0|0 0 0|1 0|0| +-------------+-----------+---------+-------+-----+---+-+ +/"1 @: (-.@:i. lb) 1 3 2 4 3 1 1 2 NB. Count of subsequent duplicates 2 1 1 0 0 1 0 > guess why it takes up so much more memory. ( I am afraid that memory is not my department ;) > > a =: ?. 1 + 50000 $ 50 > ts 'i.~ ListBlocK a' > 43.049772806320355 658944 > ts 'i.~ lb a' > 33.016631443381769 1313920 > > --- Jose Mario Quintana > <[EMAIL PROTECTED]> wrote: > > > > On Behalf Of Pascal Jasmin > > > Sent: Tuesday, September 26, 2006 4:18 PM > > > A few applications, > > > > > > raw list of subsequent duplicates > > > ((-.@:i.)) ListBlock (,<) 1 3 2 4 3 1 1 2 > > > > > > +-------------+-----------+---------+-------+-----+---+-+ > > > |0 0 0 0 1 1 0|0 0 1 0 0 0|0 0 0 0 1|0 0 0 0|0 0 > > 0|1 > > > 0|0| > > > > > > +-------------+-----------+---------+-------+-----+---+-+ > > > > > > Count of subsequent duplicates (boxed then > > unboxed) > > > > ((+/@:-.@:i.)) ListBlock (,<) 1 3 2 4 3 1 1 2 > > > 2 1 1 0 0 1 0 > > > > > > Link to next duplicate item. > > > ((i.~)) ListBlocK 1 3 2 4 3 1 1 2 > > > 4 2 4 4 3 0 1 > > ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
