> 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

I tried to compare the performance of a straightforward,

   lb=. ({.`) (`}.) (`:6) \. (}:@:)

   U lb
}:@:(({. U }.)\.)

   (i.~) lb  1 3 2 4 3 1 1 2
4 2 4 4 3 0 1

vs. ListBlocK; but I got,
   
   ((i.~)) ListBlocK 1 3 2 4 3 1 1 2
|value error: xxs
|   1<#y['h y'=.    xxs y
   


> 
> --- Pascal Jasmin <[EMAIL PROTECTED]> wrote:
> 
> > This control structure is a variation on the /
> > adverb.
> > There is both an adverb form, and more general
> > conjunction form.  The adverb u ListBlocK 1 2 3 4 is
> > equivalent to:
> > (1 u 2 3 4) , (2 u 3 4) , (3 u 4)
> >
> > The more general conjunction form (u ListBlock v) 1
> > 2
> > 3 4 is equivalent to:
> > (1 u 2 3 4) v (2 u 3 4) v (3 u 4)
> >
> > and also equivalent to
> > v/ (u ListBlocK) 1 2 3 4
> >
> > The control structure is more equivalent to
> > lisp/haskell style which use explicit functions that
> > have the entirety of the tail available as a
> > parameter
> > to combine with successive head items.  The most
> > practical operation is relationship testing between
> > members and the rest of the list, in n*n/2 time
> > instead of n*n.
> >
> > ListBlock=: 2 : 0
> >  NB. Loops through list passing head u rest to dyad
> > u.
> >  NB. results accumulated to lastreturns v newresult
> >  NB. Purpose: like / but passes full rest of list on
> > right.
> >  try.  last=. (v/ i.0) catch.  last=. i.0 end.  NB.
> > v
> > must have an identity function defined, or otherwise
> > deal with i.0 v (h u y).
> >  while. 1<#y [ 'h y' =. xxs y do.
> >   last=. last v h u y
> >  end.
> >  last=. last v h u y
> > )
> > ListBlocK=: (ListBlock ,)
> >
> >    f=: 4 : 'x + +/ y'
> >   (f ListBlocK) 1 2 3 4
> > 10 9 7
> >    (f ListBlock +) 1 2 3 4
> > 26
> >
> > Maybe InsertWhole would be a better name for it?
> >
> > __________________________________________________
> > Do You Yahoo!?
> > Tired of spam?  Yahoo! Mail has the best spam
> > protection around
> > http://mail.yahoo.com
> >
> ----------------------------------------------------------------------
> > For information about J forums see
> > http://www.jsoftware.com/forums.htm
> >
> 
> 
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
> ----------------------------------------------------------------------
> 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