Nice first program. I'm afraid pretty much all that there was to say
about it has been said already, so all I'll add is my personal
preferences for documentation.

I skimmed through several of the included books, before settling
on the actual Dictionary introduction. This is probably just
personal, as I liked the barebones style of it. Another good book
is Learning J by Roger Stokes. It's a little smoother, and although
I haven't read it to the end, I believe it touches some more
technical aspects (such as how to write fast J code) than the
Dictionary does.

Of course I would recommend simply finding some random
problem to solve (not too complicated!) and just sit down and
solve it. A good place to start is www.projecteuler.net 
<http://www.projecteuler.net/>.
The labs (Help | Studio | Labs) are also full of interesting stuff.
The essays at http://code.jsoftware.com/wiki/Essays 
<http://code.jsoftware.com/wiki/Essays> are also
really great. I sometimes just pick a random one and end up
learning not only about J but about all kinds of other interesting
things as well.

Just remember, J is not a language you can learn in two weeks.
I've been at it for several months, and only as a hobby. It's 
quite addictive. I still can't fully grasp some of the primitives,
and I imagine some more seasoned users aren't completely
sure how to use the more complicated ones (H. or ;: for example).

Luckily the documentation for J is the best I've seen for any
language, period. Press CTRL-F1 often.

Louis

> On 13 Mar 2016, at 22:53, Marshall Lochbaum <mwlochb...@gmail.com> wrote:
> 
> Although it's perhaps not as important early on as Henry's excellent
> advice, I would like to advocate for good use of whitespace and grouping
> in J programming. Putting less space around parts which are evaluated
> first (generally adverbs) and more around those which are evaluated last
> makes it a lot easier to interpret the code and mentally group its parts
> together. So I would write (hoping for no line wrap)
> 
> isAnagramOf =: 0: ` ([: */ =&([: /:~@tolower ' '&i. # ])) @. (=&([: # ' '&i. 
> # ]))
> 
> Here I have replaced a few (@) constructions with ([:), as ([: u v) is
> equivalent to (u@:v) but frequently requires fewer distracting
> parentheses. Many programmers prefer (@:) instead, but it is a good idea
> to use (@:) unless there is an actual reason to use (@). I would
> probably further replace ([: # ' '&i. # ]) with (' '&i. #@:# ]), and
> subsequently realize that dyad (#@:#) is the same as (+/@:[), giving
> (' '&i. +/@:[ ]) or (' ' +/@:i. ]), and similarly group (*/) with (=) as
> (*/@:=), since this becomes an easily-understood idiom.
> 
> The two concrete points here are:
> - Use whitespace to show precedence: tighter spacing around operators
>  with less precedence.
> - Replace ([: u v@:w) with ([: u@:v w) when u and v are related. This
>  holds for (&:) instead of (@:), and in monad and dyad forms.
> 
> And the more general rule: pay attention to how your code is written! It
> can suggest a lot of relationships that help the reader (usually you) to
> understand what is happening.
> 
> Marshall
> 
> On Sun, Mar 13, 2016 at 03:21:15PM +0000, Adam Tornhill wrote:
>> 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

Reply via email to