Marshall Lochbaum writes:
2) Yes, fills are a pain. In general, you should keep ragged data in boxes
rather than letting J concatenate it and fill out the shorter elements. I
can think of a few cases where fills are useful (working with polynomials,
which ideally are infinite lists where all but a finite number of elements
are zero, is one), but otherwise they will probably just damage your data.
I disagree with this. For example, suppose you have a set of names.
Compare the performance of a list of boxed names vs. a table of names,
padded by fills to have the same number of columns:
c=: 7 + 1e6 ?@$ 13
n=: +/c
v=: ((i.n) e. 0,+/\ c) <;.1 a.{~97+n ?@$ 26
m=: >v
$v
1000000
$m
1000000 19
ts=: 6!:2 , 7!:2@]
ts 'v i. v'
0.346757 1.25835e7
ts 'm i. m'
0.24254 1.25836e7
7!:5 <'v'
6.81943e7
7!:5 <'m'
3.35544e7
On Thu, Jun 27, 2013 at 8:21 AM, Marshall Lochbaum <[email protected]>wrote:
> 1) Fills need to be as unobtrusive as possible. This means they need to
> keep the original array intact, and look distinct from the rest of the
> array. Filling the front of an array would change which elements are at
> which indices by moving each element up a few indices. This makes it
> difficult to consistently index the array, so that's out. Cycling the
> array is a bit more reasonable, but it has a few problems. First, the
> cycled elements will look like data, making it hard to distinguish where
> the fill has been added. Second, doing a cycle fill multiple times is
> not equivalent to using one larger fill:
> ]a=.i.4
> 0 1 2 3
> 8$6$a
> 0 1 2 3 0 1 0 1
> 8$a
> 0 1 2 3 0 1 2 3
>
> 2) Yes, fills are a pain. In general, you should keep ragged data in
> boxes rather than letting J concatenate it and fill out the shorter
> elements. I can think of a few cases where fills are useful (working
> with polynomials, which ideally are infinite lists where all but a
> finite number of elements are zero, is one), but otherwise they will
> probably just damage your data.
>
> Marshall
>
> On Wed, Jun 26, 2013 at 11:00:45PM -0700, Michal D. wrote:
> > Hi All,
> >
> > I was wondering if any J implementors have some insight to share.
> >
> > (1) Is there a reason why fills are put in the places they are? Are
> there
> > any alternatives that were also explored? One might imagine filling the
> > front of an array instead of the back, or cycling through the elements of
> > the array instead of inserting fills.
> >
> > (2) They seem a little bit more tricky and unwieldy than I originally
> > thought. Would others agree?
> >
> > Cheers,
> >
> > Mike
> > ----------------------------------------------------------------------
> > 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