[Jprogramming] Request for code critique '&. Hello'

John Randall randall at andromeda.rutgers.edu
Fri Feb 10 06:00:44 HKT 2006


Miller, Raul D wrote:
> John Randall wrote:
>> More generally, I try to write tacit code when possible.  An
>> obstacle I run into is nested if statements.  While I know I
>> can replace them using @., I almost never do because I cannot
>> understand the result.  Does anyone have a way of getting around this?
>
> (Maybe you mean like if=:@. ?)
>
> Personally, when I use @. I try to keep the line fairly simple.
> .... Raul's excellent suggestions deleted.

Raul:

I am thinking of a case like

if.     c1 y. do. a1 y.
elseif. c2 y. do. a2 y.
elseif. c3 y. do. a3 y.
elseif. 1     do. default y.
end.

I can rewrite this as

((default`a3 at .c3)`a2 at .c2)`a1 at .c1

but it is very easy to go wrong.

I would like to be able to generate this code from an array of gerunds like:

c1 a1
c2 a2
c3 a3
1: default

(with appropriate J syntax).

Best wishes,

John



More information about the Programming mailing list