Good discussion, thank you. More inline.

--- Roger Hui <[EMAIL PROTECTED]> wrote:

> a. What is "scan"?  If it is f/\ and f/\. then
> there is little meaningful to be said in addition
> to what I have already said:  If the interpreter
> "knows" that f is associative f/\ is fast, i.e. 
> O(n); if not, f/\ is O(n^2).  In contrast, f/\. 
> is always O(n).

In this particular example, it is the narrow meaning
as it is called in APL [1]. However, thinking further
in terms of systematic guide, scan in wide sense would
also be some other operators that apply a verb in
an equivalent of a "for" loop, including infix and cut
in multi-dimentional sense. On the other hand almost
anything in J is equivalent to a "for" loop, so there
need to be a boundary to this wideness.

[1] C. Burke and R. Hui, J for the APL Programmer.

> b. What is "direct single pass scan" and what is
> "alternative multiple scan"?  

By direct single pass I meant when elements are
traversed from first to last in one go (with memory
of last iteration). The closest is u/\

   ([^:(0=])) /\ 3 0 0 2 0 4
3 3 3 2 2 4

Ideally it would model this explicit efficiently

dirscan=: 1 : 0
  z=. 1{.y
  for_i. 1+i._1+#y do.
    z=. z,((i-1){z) u i{y
  end.
)
   ([^:(0=])) dirscan 3 0 0 2 0 4
3 3 3 2 2 4

Multiple scans in too wide sense here
means that there are mutiple for loops
applied to the argument, in this case
just primitives, not "scanning" operators.

   ({~ [EMAIL PROTECTED] >./\@:* 0~:]) 3 0 0 2 0 4
3 3 3 2 2 4

This scan pattern seems so simple in explicit code,
that it's surprizing that in J to run it
efficiently it requires quite a trick:

   ([^:(0=]))~ /\.&.|. 3 0 0 2 0 4
3 3 3 2 2 4

> c. If "this problem" is the one originally posed
> -- repeat a non-fill item until the next non-fill
> item -- then I disagree that it takes a lot of
> effort to figure out in J.  Since you said that
> "this problem seems very trivial" in C, then 
> perhaps I am entitled to tell you that I solved 
> the problem instantly in J.  (I mean that I got 
> the crux of the solution instantly.  Actually
> programming it would probably have taken 5 
> minutes or so.)

Not all are so fortunate. How long will it take a
J beginner or even an enthusiast? I consider myself
fairly proficient in regex, but I consult guides
all the time. This is an arguments of this particular 
aspect of programming in J as a mental capacity 
or knowledge acquisition.

> d. If you mean by "that reference" "Appendix B:
> Special Code" of the dictionary, then I should 
> point out that Appendix B has been mentioned 
> just recently in this forum.

By reference I meant a link to the fictional
Guide to Scans in J. Speaking of Appendix B, it
is a good reference, but it does not have the
connecting the dots part, which would be in a guide.

> Anyway, if you care about efficiency, then
> Appendix B is a standard place to look.  
> On the other hand, it is also reasonable to 
> program in J without regard to Appendix B,
> and then tell us about it if your J program 
> is slower than you expect.  (Whence most likely
> we will clear up your misconceptions :-)
> 
> Many the items in Appendix B came about when I 
> do benchmarks on programs submitted to the Forum 
> by people whom I respect, and they ran slower than
> I expect.  A number of them are "JKT specials";
> perhaps in time there will be a few "OK specials".

There are limits to feasibility of specials,
to understand them and related aspets of scans,
and because it's better to have a link to read than 
to ask questions every time, it's good to have a guide,
if such guide is possible.

> e. Pepe's tools are indeed cool.  See also Sample 
> Topic 19 in the dictionary:
> http://www.jsoftware.com/help/dictionary/samp19.htm
> You know, you really should read the documentation
> sometimes. :-)

That's an excellent example. But it's all scattered.
And our brains need some help to get it together, such
as a Wiki page with links to all such tools.


> ----- Original Message -----
> From: Oleg Kobchenko <[EMAIL PROTECTED]>
> Date: Wednesday, December 13, 2006 4:38 pm
> Subject: Re: [Jprogramming] What a drag
> 
> This is understood. What I meant by systematic is
> that Scanning is one of fundamental properties of
> J programming, as in "loopless code". Also it is
> generalized from classic APL.
> 
> So it would explore different types of scan as in
> Jose's examples and examine what properties and
> constraints they have. Such as when direct single pass
> scan would be inefficient compared with alternative
> multiple scans.
> 
> This problem seems very trivial, at least for C code.
> Yet in J it requires a lot of effort to figure out.
> It would be good, next time, just to point to that
> reference.
> 
> Is it possible, or it's like to ask for a program
> that does anything?
> 
> I also liked Jose's tool to construct and visualize
> application of verbs to arguments. It would also be
> good to centralize a collection of various such tools
> in a toolbox in Wiki. ts is another such tool,
> Primitives to Mnemonics, etc.
> 
> 
> --- Roger Hui <[EMAIL PROTECTED]> wrote:
> 
> > Appendix B of the dictionary
> > http://www.jsoftware.com/help/dictionary/special.htm
> > says that:
> >
> > +/\  monad          also * and - ; on Windows, assembly code for integer 
> > arguments
> > +/\.  monad          also * and - ; on Windows, assembly code for integer 
> > arguments
> >
> >
> >
> > ----- Original Message -----
> > From: Oleg Kobchenko <[EMAIL PROTECTED]>
> > Date: Wednesday, December 13, 2006 1:32 pm
> > Subject: RE: [Jprogramming] What a drag
> >
> > > OK. So +/\ is special code then.
> > > Thanks, Raul and Jose.
> > >
> > >   Q=: _2+?1000$5
> > >   (+/\ -: ([+])/\) Q
> > > 1
> > >   (+/\ -: ([+])~/\.&.|.) Q
> > > 1
> > >   ts '+/\ Q'
> > > 1.02999e_5 5248
> > >   ts '+/\.&.|. Q'
> > > 1.50313e_5 9728
> > >   ts '([+])/\ Q'
> > > 0.311365 18304
> > >   ts '([+])~/\.&.|. Q'
> > > 0.000485823 10496
> > >
> > >
> > > Still, it's kind of murky.
> > > Is there a link where it is systematically treated?
> > >
> > > Also here is a relationship,
> > >
> > >   -/\1 2 3 4 5
> > > 1 _1 2 _2 3
> > >   -/@|.\.&.|.1 2 3 4 5
> > > 1 _1 2 _2 3
> > >  
> > >   -/\.&.|.1 2 3 4 5
> > > 1 1 2 2 3
> > >   -/@|.\1 2 3 4 5
> > > 1 1 2 2 3



 
____________________________________________________________________________________
Yahoo! Music Unlimited
Access over 1 million songs.
http://music.yahoo.com/unlimited
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to