Brian McGuinness:
> But the "end pathname with a slash" problem
> could be handled the same way:
> path =. path, '\' -. {: path
That's beautiful. It's a new tool for me, and a perfect example of the kind
of sentiment I was trying to express. I might render this in English as
"append to the path the relative complement of '\' wrt its last character",
or even more directly, "ensure the last character of the path is '\'", which
is exactly what we want to say.
In the context of a scalar affixation, this is a better expression than the
original (, '\' #~ '\'~:{:) . I say that because it rests on even fewer
assumptions. In particular, # is sequence-oriented, but as we are dealing
with a scalar we do not care about (or have any) order; the set-oriented -.
is simpler, more honest, and more descriptive (as opposed to prescriptive,
like #). A cue that your expression is simpler (and better) is also one of
its nicer consequences: we notice that where the original expression
required 2 references to the path separator, yours required only 1.
Which is to say, while the original expression bragged (over the pseudocode)
that its predicate and consequence are indivisible, in yours, they are
identical!
-Dan
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm