This is another solution, much simpler, where mu produces the same results as trap.
slopes =: _1 1%1 0 1#}:-}.
ends =: {.,{:
intercepts =: _1*ends*slopes
mu =: [: <./"1 (1 <. 0 >. interce...@] + [ * slo...@])"0 1
And the following produces the same result as before.
x:((],:3&+)i. 15) ([,:mu)"1/_4]\0 5 10 14 2 6 10 14.5
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
