Is their a better way to create a verb that toggles as defined here?

     toggle =: 4 : 0
t =: -. t
)
     t =: 0  NB. initialisation

Consider the calculation that might occur in a bank, where growing
deposits yield a growing interest rate:

1.03*300+1.025*200+1.02*100

To evaluate it the toggle verb allows to write:

   (+`* @. toggle)/ 1.03 300 1.025 200 1.02 100

I dislike the global variable (t), certainly there are better ways to do
the calculation.

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to