Brian Schott:
> Regarding your idea to replace >: with epsilon, that is intriguing,
> but I have not had an opportunity to study it.
You'll find an example of this in the first message of this thread; I used
_1e_16 as my epsilon. While this works today, because I. isn't tolerant, I
don't like it because it will break if I. ever becomes tolerant, or if
deltas of that magnitude are ever significant in my application domain.
> Do you think the pair of I.'s in F could be made more efficiently
> calculated to require a single calculation? Years ago, I believe it
> was Henry who showed me how such an efficiency can be accomplished in
> simpler verb trains.
Nested trains can definitely be leveraged to re-use calculations. The issue
becomes retaining & passing around more than 2 arrays (the max a J verb can
consume). In this case, we already need access to x and y, and retaining I.
for re-use effectively gives us a 3rd argument. So we need to do a little
boxing to join at least 2 of the arguments into a single argument, and
little unboxing later to pick it apart:
NB. Original
F0 =: I. - ] < I. { [,_:
l =. 0 {:: [
r =. 1 {:: [
F1 =: ,&< (] - r < ] { l,_:)f. I.
2 3 5 (F0-:F1) 0 1 2 3 4 5 6 7
1
In the nested train above, ] refers to I., which is only calculated once,
and l and r refer to the original left and right arguments (i.e. of the
whole, outer, verb). The f. isn't required but I don't like names to
persist if I'm not going to use them again, so I often assign my helper
utilities locally, then fix their values into my persisted names.
-Dan
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm