2010/11/15 Björn Helgason <[email protected]>:
> It would be interesting to know how many J ers can easily read tacit
> programs.
>
> A line like
>
> [: +/ [: > [: ".&.> [: [ [: {.&.> [: [ [: ":&.>@p: i.
>
> This is something I am not too comfortable to read nor write just like that
> even if I do know what it is supposed to do.
>
> Question is if people see it as a better way to program like this tacitly
> than just do it in more lines and easily understood steps?
My first impression on reading that line is that it
is horribly verbose.
Reading from right to left, we have:
generate the first n indices
find the first n primes
format them and put them in boxes
And here it gets stupid:
identity function
take them out of boxes, get the first character, put them back in boxes
identity function
take them out of boxes, convert character to digit, put them back in boxes
take them out of boxes
Obviously, you can get rid of those identity functions,
and that would shorten the line, and make the result
simpler (and, thus, easier) to read.
But, also, why all this putting things in boxes? That is
just wasted motion, which makes the expression
verbose (and distracts the reader from the part
that actually matters).
So, yes: you can make this kind of thing simpler by
eliminating unnecessary text:
[: +/ {.&.":@>@p:@i.
That said, a person could also have trouble reading
this if they did not understand the words. To my
knowledge the only solution to that problem involves
looking up the unfamiliar words in the dictionary, or
asking someone that knows.
--
Raul
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm