On 6/23/07, Elmer Fittery <[EMAIL PROTECTED]> wrote:
Any comments on the code would be appreciated.
Well...
First off, you reuse symbols, so things like Ci or Hi mean
different things at different places in your script. More than
anything else, I'd strongly encourage you to come up with
unique names for each concept.
Secondly, you are mostly defining nouns. I would rearrange
your data slightly and then define everything as verbs operating
on that rearranged data.
More specifically, I'd define
getarray=:[: |: ".;._2]
and then use getarray to translate a block of text to a
numeric array. Then I might start defining verbs like
Op=: open=: 3&{
Hi=: high=: 4&{
Lo=: low=: 5&{
Cl=: close=:6&{
Z =: 256
n =: _1 + [EMAIL PROTECTED]
lnSq=: lnSquare=: *:@[EMAIL PROTECTED]
vol=: [: %: (Z%n) * (0.5 * Hi lnSq Lo) +&(+/) (1 - 2 * ^.2) * Cl lnSq Op
diLn=: diffLn=: -&^.
u=: Hi diLn Lo
d=: Lo diLn
c=: [: ^. Cl
... all of which operate on one of these arrays (except Z, but
close enough).
But to make that work I'd need to come up with good names for
each of these words...
Note also that as you make your expressions more concise
you almost automatically start making them more efficient
k=: 0.34%1 + n (+%-) 1
Anyways, I think some simplification would do some good,
but first you should eliminate confusing naming and I think
you should also be defining your operations as verbs rather
than as specialized nouns.
--
Raul
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm