Out of curiousity, is there any particular reason you want a tacit version?
To my eye, still not comfortable with tacit, Raul's initial solution looks simplest and most straightforward. ocrsum0=: 4 : '+/(}.x) % }:y' NB. Sum open[n+1]%close[n] - explicit (Raul's original) ocrsum1=: [:+/[EMAIL PROTECTED](]}:) NB. Sum open[n+1]%close[n] - tacit ocrsum2=: (+/@[EMAIL PROTECTED]:@(%//.@:,:)) NB. Sum open[n+1]%close[n] - tacit using "oblique" 100 101 103 104 103 102 (ocrsum0-:ocrsum2) 101 100 104 104 105 103 1 100 101 103 104 103 102 (ocrsum0-:ocrsum1) 101 100 104 104 105 103 1 Mike Day's solution using "oblique", which is the coolest, works the same for the example numbers but otherwise has some unexplained differences: open=. 100+?1e2$0 [ close=. 100+?1e2$0 open (ocrsum0-:ocrsum1) close 1 open (ocrsum0-:ocrsum2) close 0 open (ocrsum0,ocrsum2) close 99.05473 98.947048 I also liked Mike's initial approach of combining "open" and "close" into a single array as this is more "J-like": it reduces the number of items to keep in synch. On 6/7/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
Given: open =: 100 101 103 104 103 102 close =: 101 100 104 104 105 103 Calculating +/ open % close is easy, but how about +/ open(index+1) % close(index) In other words summation of the ration between today's closing price and tomorrow's opening price. Easy to do procedurally, but how to do it with tactic programming. Trying to empliment "Historical Open-High-Low-Close Volitility: Yang-Zhang" algorithm found at: http://www.sitmo.com/eq/417 Probably just rewriting something somebody else already did in J, but it is good learning new things. thanks ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
-- Devon McCormick, CFA ^me^ at acm. org is my preferred e-mail ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
