Here is a simple idiom for testing whether a number x is
contained within a semi-open interval [y1,y2).  The problem
itself is so simple and commonplace that this solution is
probably known to others, but I don't recall to have seen it
on J's web pages and it occurred to me only yesterday, so
here it is: </@:< .  E.g.:

   2.4 (</@:<) 2 3
1
   (-:-:i.10) (</@:<)"0 1 (1 2)
0 0 0 0 1 1 1 1 0 0

The simplicity of the expression I attribute to the algebraic
elegance characteristic for semi-open intervals.
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to