The programming language J , developed in the early 1990s by Kenneth E. Iverson and Roger Hui, is a synthesis of APL (also by Iverson) and FP and FL function language languages ââmade by John Backus.
To avoid repeating APL special character issues, J only uses the basic set of ASCII characters, switching to point and dot usage as inflections to form short words that are similar to digraphs . Most of the word primers (or primitive ) J function as a mathematical symbol, with a dot or colon extending the meaning of the basic characters available. Also, many characters that in other languages ââoften need to be paired (such as [] {} "" ``
or & lt;
) is treated by J as stand- - own words or, when inflection, as the root of a single character from multi-character words.
J is a very short programming language, and is best suited for mathematical and statistical programming, especially when performing operations on a matrix. It has also been used in extreme programming and network performance analysis.
Like the original FP/FL language, J supports program-level programming through the tacit programming feature.
Unlike most languages ââthat support object-oriented programming, flexible hierarchical J hierarchical schemes (where each name exists within a particular local ) can be used effectively as a framework for class-based objects and prototype-based programming-oriented.
Since March 2011, J is free and open source software under the GNU General Public License version 3 (GPLv3). A person may also purchase a source under a negotiated license.
Video J (programming language)
Example
J allows free style and function composition. Thus, the program can be very short and is considered difficult to read by some programmers.
"Hello World!" program in J is
'Hello, world!'
This hello world implementation reflects the traditional use of J - programs entered into the J interpretation session, and expression results are displayed. It is also possible to set the J script to be executed as a stand-alone program. Here's how it looks on Unix systems:
Historically, APL uses /
to show folds, so /1 2 3
is equivalent to 1 2 3
. Meanwhile, the division is represented by a symbol of classical mathematical division (obelus, ÃÆ' à ·), which is carried out with overstriking minus and colon marks (on both text terminals EBCDIC and ASCII paper). Because ASCII in general does not support overstrikes in a device-free way, and does not include per share symbols se, J uses% to represent sharing, as a visual approach or reminder. (This describes something of the mnemonic character of token J, and some quandaries imposed by the use of ASCII.)
Defines a J function named avg
to calculate the average list of generated numbers:
avg =: / % #
This is the implementation of the test function:
avg 1 2 3 4
2.5
#
calculates the number of items in the array. /
sums the items from the array. %
divides the sum by the number of items. Above, avg is defined using a three-verb carriage (/
, %
, and #
) termed fork . Specifically (V0 V1 V2) Ny
is the same as (V0 (Ny)) V1 (V2 (Ny))
indicating some power J. (Here V0, V1, and V2 shows the verb and Ny shows the noun.)
Beberapa contoh menggunakan avg
:
v =: ? . 20 $ 100
NB. vektor acak ÃÂ ÃÂv
46 55 79 52 54 39 60 57 60 94 46 78 13 18 51 92 78 60 90 62 ÃÂ ÃÂavg v
59,2
4 avg \ v
NB. moving average pada periode ukuran 4 58 60 56 51.25 52.5 54 67.75 64.25 69.5 57.75 38.75 40 43.5 59.75 70.25 80 72.5
m =: ? . 4 5 $ 50
NB. matriks acak ÃÂ ÃÂm
46 5 29 2 4 39 10 7 10 44 46 28 13 18 1 42 28 10 40 12
avg " 1 m
NB. menerapkan rata-rata untuk setiap peringkat 1 sub-judul (setiap baris) dari m 17.2 22 21.2 26.4
Ranking is an important concept in J. Significance in J is similar to the significance of select
in SQL and when
in C.
Applying quicksort, from result J Dictionary:
Here is a quicksort implementation demonstrating tacit programming. Then it involves the preparation of shared functions and does not refer explicitly to any variable. A support for fork and hook defines rules about how the argument applied to this function will be applied to its component functions.
Sorting in J is usually done using the default verb (primitive) /:
(sort up) and \:
(sort). User-defined types such as quicksort, above, are usually for illustrations only.
The following example shows the use of a standalone $:
self-reference verb to calculate Fibonacci numbers recursively:
This recursion can also be achieved by referring to a verb by name, although this is of course only possible if a verb is named:
The following expression shows pi with n digits and shows the expanded precision capability of A:
n =: 50
NB. set n as the required number of digits à Ã& lt ;. @ o . 10x ^ n
NB. precision extension 10 to nth * pi 314159265358979323846264338327950288419716939937510
Maps J (programming language)
Data types and structures â ⬠<â â¬
J supports three simple types:
- Numerical
- Literal (Character)
- The box
Of these, numeric has the most variants.
One of the numeric types J is bit . There are two bit values: 0 , and 1 . Also, bits can be formed into lists. For example, 1 0 1 0 1 1 0 0
is a list of eight bits. Syntactically, A parser treats it as a single word. (Space characters are recognized as characters forming words between other numerical words.) A long list of arbitrary is supported.
Furthermore, J supports all the usual binary operations on this list, such as and , or , exclusive or , play , shift , not , etc. For example,
1 0 0 1 0 0 1 0. 0 1 0 1 1 0 1 0 NB. or 1 1 0 1 1 0 1 0
3 |. 1 0 1 1 0 0 1 1 1 1 1 NB. play 1 0 0 1 1 1 1 1 1 0 1
J also supports higher order bit sequence. They can be formed into two dimensions, three dimensions, etc. The above operations perform equally well on this array.
Other numeric types include integers (eg, 3, 42), floating point (3.14, 8.8e22), complex (0j1, 2.5j3e88), expanded precision integers (12345678901234567890x), and larger rational fractions (1r2 extension) , 3r4). Like bits, this can be formed into arbitrary lists or arbitrary arrays. Like bits, operations are performed on all numbers in the array.
The bit list can be converted to an integer using the verb #.
. An integer can be converted to a bit list using the #:
verb. (When deciphering J, .
(period) and :
(colon) are word-forming characters, they are never tokens unless they are preceded by a space character.)
J also supports the literal type (character). Literal is enclosed in quotes, for example, 'a'
or 'b'
. The literal list is also supported using ordinary conventions placing some characters in quotation marks, such as 'abcdefg'
. Typically, the individual literals have an 8-bit width (ASCII), but J also supports other literals (Unicode). Numerical and boolean operations are not supported on literals, but collection-oriented operations (such as rotate) are supported.
Finally, there is a box data type. Typically, data is entered into the box using the & lt;
(without the left argument; if there is a left argument, this will be less than ). This is analogous to C & amp;
(without the left argument). However, where results from C & amp;
has a semantic reference, the result of J's & lt;
has semantic value. In other words, & lt;
is a function and produces results. The result has 0 dimensions, regardless of the data structure contained. From the point of view of a J programmer, & lt;
inserting data into the box and lets work with the box arrangement (it can be assembled with another box, and/or more copies can be made from the box).
& lt; 1 0 0 1 0 --------- | 1 0 0 1 0 | Â Â ---------
The only type of collection offered by J is an arbitrary array of dimensions. Most algorithms can be expressed very briefly using operations in this array.
J's array is typed homogeneously, eg list 1 2 3
is a list of integers even though 1
bit. For the most part, this type of problem type is transparent to the programmer. Only certain special operations disclose the different types. For example, the list of 1.0 0.0 1.0 0.0
will be treated exactly, by most operations, as a list of 1 0 1 0
.
J also supports rare numerical arrays where non-zero values ââare stored with their index. This is an efficient mechanism where relatively few non-zero values.
J also supports objects and classes, but these are artifacts of things that are named, and not data types. Instead, literal boxes are used to refer objects (and classes). Data J has a semantic value, but objects and classes require reference semantics.
Another type of pseudo - which is associated with a name, not a value - is a memory mapped file.
Documentation
Documentation J includes a dictionary, with words in J identified as a noun, verb, modifier, and so on. The main words are listed in the vocabulary, where each part of their words is indicated using markup. Notice that the verb has two forms: monadic (argument only to the right) and dyadic (arguments on the left and on the right). For example, in ' -1
' hyphens is a monadic verb, and in ' 3-2
' hyphens is a dyed verb. The definition of monadics is largely independent of the dyadic definition, regardless of whether the verb is a primitive verb or a derivative verb.
Control structure
A provides the control structure (details here) similar to other procedural languages. Prominent control words in each category include:
-
assert.
-
is disconnected.
-
continue.
-
for.
-
goto_label.
-
if. other. elseif.
-
returned.
-
select. capital letters
-
throw.
-
try it. catch.
-
when. while.
See also
- K (programming language) - other languages ââaffected by APL
- Q - KDB language and a new combined version of K and KSQL.
References
External links
- Official website - JSoftware, author of J
- Learning J - Introduction to Programming Lang J by Roger Stokes
- A Wiki - Showcase, documentation, articles, etc.
- A Archive Forum - Language Discussion
- Cliff Reiter - Chaos, fractals, and mathematical symmetry, in J
- Ewart Shaw - Bayesian inference, medical statistics, and numerical methods, using J
- Keith Smillie - Application of array programming language statistics, especially J
- John Howland - Research on the parallelization of array programming languages, especially J
Source of the article : Wikipedia