Hi, Raul!

On 5/16/21, Raul Miller <[email protected]> wrote:
> You left out your example data for 'filer', but you gave enough detail
> that I think I can see what you are trying to do.

The following (which I did show) was the untransposed original
version, downloaded from Yahoo Finance:

      Date        Open   High     Low      Close    Volume
┌──────────┬──────┬──────┬──────┬──────┬────────┐
│2020-03-06│126.70│128.33│124.52│127.73│8193300 │
├──────────┼──────┼──────┼──────┼──────┼────────┤
│2020-03-09│120.16│122.41│117.28│117.81│10757500│
├──────────┼──────┼──────┼──────┼──────┼────────┤
│2020-03-10│122.78│124.88│115.76│124.77│11410700│
├──────────┼──────┼──────┼──────┼──────┼────────┤
│2020-03-11│121.01│122.58│116.38│117.97│8446500 │
├──────────┼──────┼──────┼──────┼──────┼────────┤
│2020-03-12│109.65│109.80│102.28│102.81│12512700│
└──────────┴──────┴──────┴──────┴──────┴────────┘

What I did then was to transpose it (and called it filer = file r) and
applied the following instructions which retained only the Date, High,
Low, and Close data:

  filer=. 5 {. filer
  filer=. 1 0 1 1 1 # filer

These were followed by the J code I showed in my previous email.

> That said, I think that I would split this up into two different routines:
>
> One routine would deal with unpacking the "rows" (or "inverted
> columns) from your data and amending the result. (And possibly either
> converting back to character or ensuring that both character and
> numeric arguments are supported or possibly not - for now, I'll follow
> the pattern from your example.)
>
> The other routine would deal with the numeric "rescaling". We could
> either have different routines here (one for each different kind of
> rescaling) or we could use a switch statement and pack them all
> together like you did. Either way works. This routine would be an
> argument for the other routine. (So the other routine would be an
> adverb.)
> ...
> hiloclose=: 0 0 1 1 1 0
>
> amender=:{{
>   ndx=. I.x NB. index vector from bit vector
>   update=. u 0&".@> x#y
>   (<"0 update) ndx} y
> }}
>
> rescaler=:{{
>   select. pricetype=. x
>     case. 1 do. y
>     case. 2 do. 10 * %: y
>     case. 3 do. 100 * 10 ^. y
>   end.
> }}
>
> Example use:
>    hiloclose 1&rescaler amender filer
>    hiloclose 2&rescaler amender filer
>    hiloclose 3&rescaler amender filer
>  ...
> Now... of course, you might actually want to avoid the amends that I
> assumed you wanted from your textual description. Or you might want
> other things to be different. So this is only an approximation of what
> you might do.
> ...
> And, of course, rather than have the three different rescaling verbs
> be 1&rescaler 2&rescaler and 3&rescaler you might instead give each of
> them a significant name.
>
> Still... perhaps this would be useful to you.

Thanks so much, Raul, for your response!  I'm 75 and continue to learn
new things from replies to questions I've posed to this J programming
group.  I have always loved learning during my entire life so far, and
J is a delightful challenge for my mental skills.  Older folk like me
often work crossword puzzles or Sudoku to keep their minds sharp--I do
J programming for various computer software challenges!  I programmed
as a hobby from 1975 to 2009, using various versions of BASIC over the
years.  (I owned an original MITS Altair 8800, for which Bill Gates
and Paul Allen wrote a BASIC interpreter and thus started Microsoft.
Subsequently, I owned an Amiga 1000, and multiple IBM PC clones in
succeeding years.)  In 2006 my library's IT department head suggested
that I might take a look at J, and, as they say, the rest is history.

Although I'm now generally comfortable programming in J (except for
occasional stumpers for which I need to ask for help in this group),
I'm at a point where I would like to learn how to write GUIs in J and
how to write visually oriented J programs (such as stock market
charting programs).  I think it may be challenging because, from my
initial investigating, there seems to be *extremely* little
information (including coding samples) available about these aspects
of J programming.

Again, thanks so much, Raul!

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

Reply via email to