I'm trying to use J more in my daily calculations in addition to programming.
I was working with some simple margin % calculations in a one liner 1- %~/ +/ (100 5) * _2[\ (10 3 7.5 2) I'd like any ideas on how others would do this type of 'spreadsheet' calculation. I'm pretty happy with it, but wondering if there's a more clear way of expressing it in a one liner. Margin % is calculated as 1 - Extended Cost / Extended Price Or more traditionally as Price - Cost / Price In the example above, I have units as 100 and 5 and prices of 10,7.5 and costs of 3 and 2 Price & Cost _2[\ (10 3 7.5 2) 10 3 7.5 2 Extended Price & Cost: (100 5) * _2[\ (10 3 7.5 2) 1000 300 37.5 10 Total Cost & Price +/ (100 5) * _2[\ (10 3 7.5 2) 1037.5 310 Margin % 1- %~/ +/ (100 5) * _2[\ (10 3 7.5 2) 0.701205 Any ideas on making it more clear are welcome ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
