Rather than using a rank 1 operation, I'd prefer to use a
column-at-a-time approach (in other words: transpose the table before
working on it).

I think that performance should be better, and the expressions are
easier (in my opinion) to create.

Ndx=: 3 :0"0
  {. y&{::`''
)

ColNdxs=: 3 :0
  #('`',y)=: Ndx i.#;:y
)

   ColNdxs 'A B C D E F G H I J K L M N O P Q'
17

   (((A * B) + C) - ((F - G) * (Q + B))) |:i.5 17
19 376 1311 2824 4915

Does this approach create problems for you?

Thanks,

-- 
Raul


On Tue, Oct 6, 2015 at 2:16 PM, John Baker <[email protected]> wrote:
> The other day I was converting spreadsheet formulas that applied between
> columns to J operations on numeric tables.
>
> One such formula was:
>
> ((I - E) + R) - D
>
> Where the verbs -,+ work on columns. To convert this to a simple J
> expression you can "Iversonize".
>
> D -~ R + E -~ I
>
> which leads directly to the nice little verb (cops):
>
> cops=:  -~`+`(-~)`:3"1
>
> That will do all the operations on each row in one swoop.
>
> The question arises. Given an arbitrary parenthesized formula with only
> dyadic verbs as text:
>
> '((A * B) + C) - ((F - G) * (Q + B))'
>
> Return the  Iversonized gerund expression and the column permutation needed
> to get an expression like (cops).
>
> I've been doing this by hand but if anyone cares to dig into this and crank
> out a solution if would help many of us that are punished by spreadsheets.
>
> --
> John D. Baker
> [email protected]
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to