i got a real buzz actually making j do something for me!
but what i've done is a little cumbersome -- can some
j minds make some suggestions to what's below? it
maps a number of files from stock market data. and
how can i find a yearly average of closing prices?
require'jmf'
cs =: ;:' y I m I d I open F high F low F close F vol I'
tcs =: ;:' B C I F X'
tys =: JB01,JCHAR,JINT,JFL,JCMPX
NB. construct names and types matrix from cs
NB. from 13 : '(2,((#y)%2)) $ y' i.8
nts =: ([: |: ] $~ 2 ,~ 2 %~ #) cs
NB. join boxed strings
NB. from 13 : '<(>x) , >y'
sj =: [: < ([: > [) , [: > ]
NB. make filenames from cs (via nts)
fns =: (((<'./'),(0{]),(<'.'),1{])"_)"1 |: nts
NB. lookup types
ts=: tys{~ tcs i. 1{nts
maps =: (0{nts),.sj/"1 fns
NB. map 'em
ts map_jmf_"(0 1) maps
NB. ? howto find average open by year
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm