I don't disagree with what you say.

Dan seemed to be saying, Can we read J without the
interpreter, rather than, Can we write readable code?

In my own code I have about 4 lines of comments per line of code
on the average.  IMO the readability comes from good design
and good commenting.

But in the spirit of Dan's post, you have asked a good question:
why the |. ?  There is one performance reason and one functional
reason.

And, -.~ here does not do list-.table, but is repeated
list-.list .

Just for fun, I wrote a function header as I would have if
this were a verb in my library:

NB. Monad.  Calculate the list of primes less than y+2
NB. y is a scalar
NB. Result is the list of primes < y+2, in ascending order
NB. We create the list 1..y+1; then we reverse the list to get
NB. y+1..1, and create the multiplication table of that with the
NB. list 2..y+2.  The last item of the table is the list
NB. of candidate primes, and the other items of the table
NB. are multiples of those numbers.  We then remove each
NB. set of multiples from the list of candidates.  This is a
NB. sieve but we are sieving with all multiples, not just
NB. multiples of primes.
NB.
NB. The table goes from big numbers to small numbers so that
NB. the list of candidates is thinned out as quickly as
NB. possible.

Henry Rich

> -----Original Message-----
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On Behalf Of John Randall
> Sent: Friday, April 04, 2008 9:19 PM
> To: General forum
> Subject: RE: [Jgeneral] How readable is J?
> 
> Henry Rich wrote:
> > -.~/@(|. */ >:)@:>:@:i.
> >
> 
> This is obviously a shorter solution to the problem, but I 
> would argue it
> is less readable than Dan's original posting, even though it 
> is readable
> in the broader sense.
> 
> I tend to favor @: over unbroken trains, and I think that 
> helps in your
> posting.  There are a couple of points that will throw a reader.
> 
> 1. We are calculating all products of a list with itself.  The |. is
> obviously lining them up in some order, but why?
> 
> 2. While using -. is good, I bet most readers do not know the 
> ranks (0 _
> _) and then (list)-.(table) could be anyone's guess.
> 
> I think Dan's original question was not completely formed.  If you are
> talking about readability, you need to know the audience.  I 
> believe the
> important audience is intermediate J users, who can write explicit
> functions and do some simple tacit programming, and who want to get
> further.
> 
> Best wishes,
> 
> John
> 
> 
> ----------------------------------------------------------------------
> For information about J forums see 
> http://www.jsoftware.com/forums.htm

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to