Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>J is my primary programming language for Project Euler and for personal use at work. I've never come across a better language for array processing, and the tacit programming paradigm is both useful and thought-provoking once you get the hang of it. (Useful because it's thought-provoking, in fact.) Reaching entry-level competence in the language is difficult, and reading other people's code is an intellectually disciplined activity, but perseverance has major payoffs because of the language's power, flexibility and conciseness. </p> <p>That said, the reason why I reserve it for <em>personal</em> use at work is that (1) nobody else at work uses it, (2) the learning curve is steep enough so that it's not reasonable for me to ask my colleagues to pick it up, and (3) the fact that you can build intricate programs in one line of code makes it challenging to read a line of code, especially if you didn't write it yourself. (I expect to spend at least half an hour studying a line of code that uses ten or more operators, unless they were used in such a way that I understand the underlying principles thoroughly.) </p> <p>Some examples of fun J features:</p> <p>1) Any function defined to operate on a single number can be made to operate on arrays of arbitrary rank. For example:</p> <pre><code>NB. totient(n) = n * \prod_{p|n} (1 - 1/p) totient=: * -.@%@~.&amp;.q: NB. Finding the totient of 10 totient 10 NB. Finding the totient of all numbers from 1 to 10 totient"0 (1+i.10) </code></pre> <p>It's exactly the same function, just operating on the atoms (single-element components) of a 1xN input array. Similarly, you can take a function defined to work on rank-two arrays (matrices) and apply it to any array of higher rank just by using the " (rank) conjunction. </p> <p>2) You can take just about any theoretically invertible function in J and invert it by 'iterating it backwards'. For example, </p> <pre><code>NB. Converts an array of binary digits to a decimal number (#.) 1 0 1 5 NB. Converts a decimal number to an array of binary digits (#.^:_1) 5 1 0 1 </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload