Raul wrote:
> alp=: a.{~,65 97+/i.26
> f=: (('='={.&>) # }.&.>) @ (-.@(e.&alp) <;.1 ])
Alan Stebbens responded:
> Can any of you honestly say that the above sentence is
> "straightforward"? :^)
As odd as it sounds, yes. Once you learn the language (in particular the tacit
style), Raul's expression really isn't complicated
at all.
I see an @ gluing two processes together. Let's call these the
primary-processor and the post-processor. Let's look at the
primary-processor (rightmost) first.
I see a train. The right tine is ] , the identity. The middle tine is <;.1
, cut. The left tine is longer; but knowing cut
and knowing the relavant J patterns that surround it, it's almost certain it
calculates a boolean mask based on the input (to
determine where to partition that input). Looking deeper, this tine starts
with -.@ "the negation of". It ends with e.&alp .
I do not even decompose this -- it reads as a cohesive whole: "members of the
alphabet", rendering the entire verb "mark
non-alphabetic characters".
So the primary-processor simply cuts up the input into boxes, putting a
partition wherever there is a non-alphabetic character.
What about the post-processor?
Again, I see a train. The middle tine is # , which (most often) means the
left tine calculates a boolean mask to filter the
right argument. That left tine is '='={.&> , a NVV (noun, verb, verb)
train. It compares the lead item of every partition to
the character '=' , resulting in a boolean mask with one bit per partition.
The right tine removes the lead item from every
partition (because it's served its purpose). The result that only partitions
which start with '=' remain (but without that
character).
I hope that clarifies Raul's code. But remember that once you become fluent in
J, you won't have to go through this exercise.
What I've done above is basically what my teachers did for me in Spanish class:
they broke down the grammar and translated the
vocabulary (and common idioms), resulting in a lengthy explanation. Whereas
for a native speaker, no explanation is required --
he just reads the sentence "naturally". It's no different for J.
Well, maybe one thing is different. It took me 4 paragraphs to explain one
line of J. That's potency. And maybe a motivation to
become fluent.
-Dan
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm