MN> I proposed that, too. Just let me nroff that part of the original
MN> article again.
I noticed that I had not just one but three little sections on
fill and quoted just the second one. For completeness sake here
are the others.
Part 1, the "why not !. part", with nothing new here:
* Controlled Recombinations
The section on Dictionary APL contained the example
> (1 ; 2 3 ; 4 5 6)
1 0 0
2 3 0
4 5 6
In certain circumstances it might be useful to pad the vec
tors with other values than 0. One might think that the fit
conjunction !. could be used to customize the fill elements
for open, just as it can be done for overtakes:
>!.9 (1 ; 2 3 ; 4 5 6)
1 9 9
2 3 9
4 5 6
This might seem attractive at first but is not a viable way
to go. As already explained, the zeroes slip in during step
3, the recombination of the partial results. During step 2,
the open of an individual cell has no way to ``know'' what
the common result shape will be. So it is not possible to
get flexible padding by making open smarter.
The general solution would be to attach the control over
fillings not to individual verbs, but to the shape assimila
tion process in step 3.
Part 2 with the "(r;f) proposal as posted.
Part 3 proposing fill functions:
Why should one be content with mere fill VALUES? A program
mer could provide a fill FUNCTION that should be triggered
in the context of II.B's shape assimilation. The function
would be called with the short partial result and the
requested shape. A programmer could designed it to have any
desired effect, as long as results of a common shape are
generated. Common choices are:
padding with a constant
padding by repeating the last item
replicating the entire value
padding on the right instead of the left
Notice that, while these fill functions are easily pro
grammed per se, the context-dependent target shape is not
known a priori. For this reason, it cannot be done within
the current language. (The overtake is an example of the
case where the programmer explicitly requests the target
shape.)
A fill function could be specified in two ways: as a gerund
in place of the fill value in the rank extension proposed
above, or as an intrinsic characteristic of a verb, associ
ated with a verb just like obverses and identity functions.
(I NEVER missed such a facility in the last 15 years.)
Martin
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm