On Mon, Apr 27, 2009 at 3:02 PM, Brian Schott <schott.br...@gmail.com> wrote: > Raul, your versions have nice features, but they don't seem to handle > the problem of a=b or c=d.
When I look at your initial implementation of trap, I get contradictory results for these cases: 1 1 1 1 trap 1 0 1 1 2 2 trap 1 2 1 1 That said, my implementation has a problem 1 1 2 2 trap 1.5 0 Of course, this can be fixed, by adding support for this special case. For example: trap=: (1 :0) 'a b c d'=. m s=. _1 1 * % _2 -/\ m z=. - 0 3 { m (b&(<:/) *. c&(>:/)) >. [: <./ 1 <. 0 >. s * z +/ ] ) There should be a more elegant way of dealing with this issue. But note that this approach does give you explicit control over whether or not the interval is close or open, when your "trapazoids" would have sides with infinite slope. -- Raul ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm