Category:J: Difference between revisions

Content added Content deleted
imported>Katsumi
No edit summary
Line 19: Line 19:
== The J language ==
== The J language ==


A frequent reaction when one first encounters a J program is often something along the lines of "that's cheating". The thought here is that the problem could not possibly be that simple, so -- instead -- the issue must be that J was specifically designed to tackle that problem.
A frequent reaction when one first encounters a J program is often something along the lines of "that's cheating". The thought here is that the problem could not possibly be that simple, so instead the issue must be that J was specifically designed to tackle that problem.


The flip side of this issue is that J is a dialect of APL -- a language whose development started in the 1950s and which was implemented in the early 1960s. And, originally, APL was designed as a language to describe computer architecture. The implementation as a programming language was motivated by its original successes in documenting computer hardware and instructions, and the relative simplicity of its concepts.
The flip side of this issue is that J is a dialect of APL a language whose development started in the 1950s and which was implemented in the early 1960s. And, originally, APL was designed as a language to describe computer architecture. The implementation as a programming language was motivated by its original successes in documenting computer hardware and instructions, and the relative simplicity of its concepts.


== Introduction ==
== Introduction ==
Line 33: Line 33:
Object-module and imperative techniques are supported, but not required.
Object-module and imperative techniques are supported, but not required.


The J programming language was designed and developed by [http://en.wikipedia.org/wiki/Kenneth_E._Iverson Ken Iverson] and Roger Hui. It is a closely related successor to [[APL]], also by Iverson which itself was a successor to the notation Ken Iverson used to teach his classes about computers in the 1950s.
The J programming language was designed and developed by [[wp:Ken Iverson]] and Roger Hui. It is a closely related successor to [[APL]], also by Iverson which itself was a successor to the notation Ken Iverson used to teach his classes about computers in the 1950s.
<br clear="all"/>
<br clear="all"/>


Line 49: Line 49:
For example, the phrase <code>(+/ % #)</code> finds the average of a list of numbers.
For example, the phrase <code>(+/ % #)</code> finds the average of a list of numbers.


<syntaxhighlight lang="j">
<lang J> (+/ % #) 1 2 3
(+/ % #) 1 2 3
2</lang>
2
</syntaxhighlight>


To understand how this works, you might try working with simpler sentences and their variations.
To understand how this works, you might try working with simpler sentences and their variations.


<syntaxhighlight lang="j">
<lang J> +/ 1 2 3
+/ 1 2 3
6
6
+/4 5 6
+/4 5 6
Line 67: Line 70:
5
5
(+/ % #) 4 5 6
(+/ % #) 4 5 6
5
5</lang>
</syntaxhighlight>


By themselves, these experiments mean nothing, but if you know that +/ was finding the sum of a list and # was finding the length of a list and that % was dividing the two quantities (and looks almost like one of the old school division symbols) then these experiments might help confirm that you have understood things properly.
By themselves, these experiments mean nothing, but if you know that +/ was finding the sum of a list and # was finding the length of a list and that % was dividing the two quantities (and looks almost like one of the old school division symbols) then these experiments might help confirm that you have understood things properly.


== Some Perspective ==
== Some perspective ==


If you wish to use J you will also have to learn a few grammatical rules (J's parser has [http://www.jsoftware.com/help/dictionary/dicte.htm 9 reduction rules] and "shift" and "accept" - the above examples use four of those rules). J verbs have two definitions - a single argument "monadic" definition and a two argument "dyadic" definition.
If you wish to use J you will also have to learn a few grammatical rules (J's parser has [http://www.jsoftware.com/help/dictionary/dicte.htm 9 reduction rules] and "shift" and "accept" - the above examples use four of those rules). J verbs have two definitions - a single argument "monadic" definition and a two argument "dyadic" definition.
Line 97: Line 101:


Discussion of the goals of the J community on RC and general guidelines for presenting J solutions takes place at [[J/HouseStyle|House Style]].
Discussion of the goals of the J community on RC and general guidelines for presenting J solutions takes place at [[J/HouseStyle|House Style]].



== Jedi on RosettaCode ==
== Jedi on RosettaCode ==