My two cents:

Marshall wrote " Use whitespace to show precedence: tighter spacing around
operators with less precedence."

J's linear representation follows this pattern and also gets rid of
redundant parentheses and my favorite, the boxed representation, displays
the structure of the verb (or adverb).  I like them both so much that I
have them both turn on by default.  This is how your original verb shows,

   (9!:3) 5 2  NB. Setting both, the linear and boxed, representations

   (0:`((*/)@(=&((/:~@tolower)@(' ' & i.#])))))@.(=&(#@:(' ' & i.#])))
0:`(*/@(=&(/:~@tolower@(' '&i. # ]))))@.(=&(#@:(' '&i. # ])))
┌──────────────────────────────────────────────────────────┬──┬───────────────────────────┐
│┌──┬─────────────────────────────────────────────────────┐│@.│┌─┬─┬─────────────────────┐│
││0:│┌─────┬─┬───────────────────────────────────────────┐││
 ││=│&│┌─┬──┬──────────────┐││
││  ││┌─┬─┐│@│┌─┬─┬─────────────────────────────────────┐│││  ││ │
││#│@:│┌────────┬─┬─┐│││
││  │││*│/││ ││=│&│┌──────────────────┬─┬──────────────┐││││  ││ │ ││ │
 ││┌─┬─┬──┐│#│]││││
││  ││└─┴─┘│ ││ │ ││┌──────┬─┬───────┐│@│┌────────┬─┬─┐│││││  ││ │ ││ │
 │││ │&│i.││ │ ││││
││  ││     │ ││ │ │││┌──┬─┐│@│tolower││ ││┌─┬─┬──┐│#│]││││││  ││ │ ││ │
 ││└─┴─┴──┘│ │ ││││
││  ││     │ ││ │ ││││/:│~││ │       ││ │││ │&│i.││ │ ││││││  ││ │ ││ │
 │└────────┴─┴─┘│││
││  ││     │ ││ │ │││└──┴─┘│ │       ││ ││└─┴─┴──┘│ │ ││││││  ││ │
│└─┴──┴──────────────┘││
││  ││     │ ││ │ ││└──────┴─┴───────┘│ │└────────┴─┴─┘│││││
 │└─┴─┴─────────────────────┘│
││  ││     │ ││ │ │└──────────────────┴─┴──────────────┘││││  │
              │
││  ││     │ │└─┴─┴─────────────────────────────────────┘│││  │
              │
││  │└─────┴─┴───────────────────────────────────────────┘││  │
              │
│└──┴─────────────────────────────────────────────────────┘│  │
              │
└──────────────────────────────────────────────────────────┴──┴───────────────────────────┘

I find them very useful when I want to understand code written by someone
else and even my own code.


Henry wrote "Notice I used &: instead of & .  & would work here, but don't
use @ and & until you understand how they differ from @: and &: ."

I wish somebody had given me that piece of advice when I started because
bad habits die hard.  I would go even further: use  @:  instead of  @  and
 &:  instead of  &  whenever is possible.  It might seem cool to save a
character here and there, for example, writing  @]  instead of  @:]  but
clarity (for me at least) is more important.  I would also add to the list
using  &.:  instead of  &.  wherever possible.


You wrote "I also like how J forces me to re-consider how I view
programming."

That is the key and you will reach critical mass when you start to think
directly about processing chunks of data as opposed to one element at a
time; likewise, when you are thinking tacitly rather than explicitly and
you seem to be a natural tacit writer (it took me a lot of effort when I
started before I could write something similar to your sample verb).

I hope it helps

On Mon, Mar 14, 2016 at 9:58 AM, Adam Tornhill <a...@adamtornhill.com>
wrote:

> Thanks everyone for all the valuable feedback and encouraging words! Much
> appreciated.
> I've learned a lot from your responses and look forward to explore J in
> much more depth.
> Thanks!--  Homepage: www.adamtornhill.com  Twitter: @AdamTornhill
> Your Code as a Crime Scene:
> https://pragprog.com/book/atcrime/your-code-as-a-crime-sceneLisp for the
> Web:  https://leanpub.com/lispwebPatterns in C:
> https://leanpub.com/patternsinc
>
>     Den måndag, 14 mars 2016 3:40 skrev 'Jon Hough' via Programming <
> programm...@jsoftware.com>:
>
>
>  As a fellow beginner (learning for well over a year, on and off), I'll
> show a way I would do it:
>
> isAnagramOf =: -:&:(-.&' '@:/:~@:tolower)
>
> I think Henry mentioned using the above conjunctions.
> Also, as Henry said, Dissecting the verb is a great way to see what
> happened.
>
> NB. name the string literals, it makes life easier
> lhs =: 'a b C'
> rhs =: 'cB  a'
> space =: ' '
>
> load 'debug/dissect'
>
> dissect 'lhs ( -:&:(-.&space@:/:~@:tolower)) rhs'
>
>
>
> On top of JForC and Roger Stokes' book, and of course the Dictionary and
> Nuvoc, I found the "Brief J Reference" really helpful:
>
> http://www.jsoftware.com/books/pdf/brief.pdf
>
> Especially pages 17 and 18, which give a great overview (in diagram form)
> of J's conjunctions, forks and hooks, without discussing rank, which of
> course is important, but, for me at least, these diagrams really made the
> whole concept click.
>
> Regards,
> Jon
> --------------------------------------------
> On Mon, 3/14/16, Adam Tornhill <a...@adamtornhill.com> wrote:
>
>  Subject: [Jprogramming] Feedback on beginner's code
>  To: "programm...@jsoftware.com" <programm...@jsoftware.com>
>  Date: Monday, March 14, 2016, 12:21 AM
>
>  Hi all,
>  I finally decided to try to understand this fascinating
>  language. So far I've spent some evenings reading and
>  experimenting with the language. J is fun. Real fun. I also
>  like how J forces me to re-consider how I view programming.
>  Of course, that also means I'm still at a complete
>  beginner's stage, so I'd like to ask for some feedback and
>  suggestions on my first J code. I'm sure there's a lot I can
>  simplify in my code.
>  Here's the code I put together by digging around in the J
>  Dictionary:
>  isAnagramOf=:(0:`((*/)@(=&((/:~@tolower)@(' ' &
>  i.#])))))@.(=&(#@:(' ' & i.#])))
>
>  Some examples:
>    'Nag a Ram ' isAnagramOf 'Anagram'1
>     'ab' isAnagramOf 'aa'0
>  All tips and hints on both the code and learning J in
>  general would be much welcome.
>  Thanks!/Adam--  Homepage: www.adamtornhill.com  Twitter:
>  @AdamTornhill
>  Your Code as a Crime Scene:
> https://pragprog.com/book/atcrime/your-code-as-a-crime-sceneLisp
>  for the Web:  https://leanpub.com/lispwebPatterns in C:
> https://leanpub.com/patternsinc
>  ----------------------------------------------------------------------
>  For information about J forums see http://www.jsoftware.com/forums.htm
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>
>
> ----------------------------------------------------------------------
> 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