Newsgroups: comp.lang.apl
Path: watmath!watserv2.uwaterloo.ca!torn!cs.utexas.edu!zaphod.mps.ohio-state.edu!uunet.ca!geac!itcyyz!yrloc!hui
From: hui@yrloc.ipsa.reuter.COM (Roger Hui)
Subject: Re: More J Questions : Printing intermediate values of y.
Message-ID: <1992Aug4.033204.21341@yrloc.ipsa.reuter.COM>
Organization: Iverson Software Inc.
References: <1992Jul29.010314.29840@csus.edu>, <1992Jul29.214620.10230@csus.edu>, <1992Jul30.033946.20747@csus.edu>
Date: Tue, 4 Aug 92 03:32:04 GMT
Lines: 65

Re msgs from Emmett McLean.
 
> I want like a function simplex where simplex executes 'y. =. interation y.'
> so long as the first ((,$}.a) - 1) elements have a negative number.
> The psuedo code would be :
>
>    while ( 0> (( <./ , _1}. {. y. )
>    y. =. interation y.
 
This is a bit puzzling (3 left parentheses vs. 1 right parenthesis).
If I understand the intent, the following does the trick:
 
   interation ^: (_1&e.@*@}:@{.)
 
See the dictionary under u^:v, and referents leading therefrom.
 
> Also, how could t be changed to include a conditional break as shown below:
>   ...
> if (*./ 0 > bvc#factors ) then break
>   ...
 
There are lots of ways to do this.  For example:

a. Conditional execute (see below).
b. f^:b y  is f y if the noun b is 1; else is y .
c. ]`f@.p y is f y if the proposition (verb) p has value 1 on y; else is y .
d. In explicit definition,
    $.=.>b{cont;skip
  cont)
    ...
  skip)
the line(s) following "cont" are executed if the (noun) b is 1, else 
the line(s) following "skip" are executed.
 
> In some versions of APL there is an "execute" instruction which
> does provides for conditional execution contingent on the value
> of a boolean variable.  The equivalent in J looks like it is the
> ". (do) instruction.
 
In APL, the computation is  execute b/string ; in J,  ".b#string .
 
> This should be easy. What is J's equivalent to APL's []TRAP ?
 
The dyad ". .
 
> How would I step through the (LU factorization) routine below using
> 1!:1&2 ? I've tried trace =. ('1!:1&2 ', "1 m) : ''  but get a
> domain error when I type "trace a".
 
The monad 1!:2&2 writes its argument to the screen.  (This is described
on the inside back cover of the dictionary.)  It may be useful to define
a utility  print=.1!:2&2 .
 
1!:1&2 correctly signals domain error.
 
> What is the syntax to branch to labels, say s1) s2) and s3)
> contingent upon some variable , say choice_var, which takes
> execution to s1, s2, and s3 if choice_var is 0 1 or 2.
 
Labels are integer vectors, and can be selected as one would any set
of integer vectors.  For example,  > choice_var { s0;s1;s2 .

------------------------------------
Roger Hui, Iverson Software Inc., 33 Major Street, Toronto, Ontario  M5S 2K9
Phone: (416) 925 6096;  Fax: (416) 488 7559
