Newsgroups: comp.lang.apl
Path: watmath!watserv2.uwaterloo.ca!torn!utnut!cs.utexas.edu!uunet!s5!hui
From: hui@fid.morgan.com (Roger Hui)
Subject: Re: Efficient J programs
Message-ID: <1993May1.223839.29787@fid.morgan.com>
Organization: Morgan Stanley & Co., New York, NY
References: <1993Apr29.144728.4138@ll.mit.edu>
Date: Sat, 1 May 1993 22:38:39 GMT
Lines: 22

William Gilson wrote on 1993-04-29:

> As I am considering doing some substantial calculations in J, 
> the following experimental results concern me:
> 
>    6!:2 '2*i.10000'
> 0.04
>    6!:2 '2*~i.10000'
> 1.54
>    6!:2 '(i.10000)*2'
> 0.03
> 
> Is the passive to be shunned in J as in English?  

The slowness of *~ vs. * is due to that f~ does not currently
exploit any knowledge about f; i.e. f~ uses the same general
algorithm for all f, explicitly applying f to each argument cell.
For the user, the solution is not to avoid the passive case, 
but to advertise its slowness in particular cases (as you have done).
For the implementor, the solution is to implement special cases
("idiom recognition") in ~; the implemented solution will probably 
assume the form of a case statement in function swap() in file a.c.  
