Raul, your versions have nice features, but they don't seem to handle the problem of a=b or c=d.
> > trap=: 1 : 0 > 'a b c d'=. m > s=. % _1 1 * _2 -/\ m > z=. - 0 3 { m > 1 <. 0 >. [: <./ s * z +/ ] > ) > > However, if that first line annoys you too much, an > equivalent form would be: > > trap=: 1 : 0 > s=. % _2 -/\ m * _1 _1 1 1 > z=. - 0 3 { m > 1 <. 0 >. [: <./ s * z +/ ] > ) > > Finally, note that these implementation of trap support treatment > of multiple "trapezoids" at the same time: > > (2 6 8 10,. 3 5 7 9) trapa i. 11 > 0 0 0 0.25 0.5 0.75 1 1 1 0.5 0 > 0 0 0 0 0.5 1 1 1 0.5 0 0 > > FYI, > > -- > Raul > -- (B=) ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm