Viktor Cerovski <[email protected]> wrote:
> It just occurred to me that > should probably allow specification of the
> fill via !.
> in the similar manner as , does.
The dyad > already accepts a fit for comparison tolerance.
There are several verbs in which the monad and dyad accept the same kinds of
fit values (for example, #: and {.). There are none in which the monad and
dyad accept different types of values (such as fill and comparison tolerance),
and it may be inconvenient for the interpreter to do so.
There is nothing in the dictionary that would forbid this from being allowed in
the future, although !. would need to be changed to yielding verbs with empty
domains, rather than immediately reporting a domain error, much as ^: does now
(again, something that the dictionary is silent about).
For example:
>!.0 NB. Ambivalent: fill-with-0 or exactly-less-than
>!.42 NB. Monad-only: fill-with-42
However, it is possible to accomplish what you want without such a mechanism:
openfit =: 1 : '$$>@:(,!.m&.>/)@:(,:&.>)@:,'
> ;:'a mixed list'
a
mixed
list
'*' openfit ;:'a mixed list'
a****
mixed
list*
Or, if you prefer a dyadic verb (which is more amenable to tacit, rank, etc.):
openfit =: 4 : '($$>@:(,!.x&.>/)@:(,:&.>)@:,)y'
-- Mark D. Niemiec <[email protected]>
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm