Newsgroups: comp.lang.apl
Path: watmath!watserv1!utgpu!news-server.csri.toronto.edu!rpi!think.com!wupost!darwin.sura.net!haven.umd.edu!socrates!socrates!rockwell
From: rockwell@socrates.umd.edu (Raul Deluth Miller-Rockwell)
Subject: Efficiency
Message-ID: <ROCKWELL.92Feb22122907@socrates.umd.edu>
Sender: rockwell@socrates.umd.edu (Raul Deluth Miller-Rockwell)
Organization: Traveller
Distribution: net
Date: Sat, 22 Feb 1992 17:29:07 GMT

Well, now that I have the J source, I thought I'd start using J to
tabulate information about the source...  There's just one little
snag:  time.

It seems that operations like +/\ or <./\. take O(n^2) time, which is
very bad when you're dealing with a file containing, for example, 4575
bytes.  And I'm used to dealing with APLs where these sorts of
operations take O(n) time...

Once I get some of my tables built, I expect that I'd be able to
figure out how to rectify this problem.  But until then, without
resorting to C, is there any way to locate which line each character
is on, without incuring O(n^2) time???

[I'm trying to construct an emacs TAGS file, and one of my
intermediate results is a matrix which, for each character, lists the
line number it's on, and the character position of that line.  I might
be able to get by with a reduced form (only one such entry for each
line), but then there's still the problem of taking a list of search
hits (either a boolean mask or a list of integers (positions)) and
extracting from that the corresponding line entries.]

There does not appear to be any way out of this fix, using J, that
doesn't involve O(n^2) time.  [Except 1!:3, hmm...]

Anyone got any bright ideas?

Otherwise, I guess I'll write an explicit loop to wade through the
search results and append significant hits to file as it finds them.
[Is there anything less tacky that will work?]

-- 
Raul Deluth Miller-Rockwell                   <rockwell@socrates.umd.edu>
The U.S. government went another thousand million dollars into debt today.
