I see how (#/.~@])`(~.@])`[}is an inverse of monad I., but I don't see
how it is a left inverse of (presumably dyad) I. . Please explain.
Also, it would be a problem to have a dyadic inverse of a monad, no?
Duals wouldn't work. Changing the suggestion to
(#/.~)`~.`(0#~>:@(>./))}
would address that.
Henry Rich
An efficient way to turn a list of intervals into a list of
number-of-intervals-containing uses an obverse of monad (I.), which I am
increasingly coming to believe is a major feature missing from J. To
wit:
x =. 4 7 2 4 1 7 8
(10$0) (#/.~@])`(~.@])`[}"1 x
0 1 1 0 2 0 0 2 1 0
I. (10$0) (#/.~@])`(~.@])`[}"1 x
1 2 4 4 7 7 8
(/:~x) -: I. (10$0) (#/.~@])`(~.@])`[}"1 x
1
The verb ((#/.~@])`(~.@])`[}) with an appropriate left argument is an
left inverse to I. ignoring trailing zeros, and a right inverse to I.
ignoring ordering. It counts, for each number in (i.n) where n is the
length of the left argument, how many elements on the right are equal to
it. To get our interval count, we just take this count for the starts of
intervals, subtract the counts for ends of intervals, and do a running
sum:
---
This email has been checked for viruses by AVG.
http://www.avg.com
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm