Category:J: Difference between revisions

Content added Content deleted
Line 88: Line 88:
J's type hierarchy supports arrays of arbitrary size and dimension, and array contents may be numeric, character or boxed. Thus, for example, we might work with an array of boxes, each box containing a one dimensional array of characters -- or, informally: strings.
J's type hierarchy supports arrays of arbitrary size and dimension, and array contents may be numeric, character or boxed. Thus, for example, we might work with an array of boxes, each box containing a one dimensional array of characters -- or, informally: strings.


In addition to arrays, J's type hierarchy includes procedural types: verbs, adverbs, and conjunctions. These correspond to functions and metafunctions of other languages.
In addition to arrays, J's type hierarchy includes procedural types: verbs, adverbs, and conjunctions. These roughly correspond to functions (J's verbs) and metafunctions (J's adverbs and conjunctions) of other languages.


As a simple example: 2 is an array (with zero dimensions), 3 is an array, and < is a verb. The expression (2<3) compares 2 and 3 and returns a truth value indicating that 2 is less than 3. But the expression (<3) returns a box which contains the array 3. While the details here are a bit different, the general concepts should be familiar to users of other programming languages. (For example, in C, 2&3 performs a bitwise and between the two numbers, and &y returns a pointer to the value referred to by y.)
As a simple example: 2 is an array (with zero dimensions), 3 is an array, and < is a verb. The expression (2<3) compares 2 and 3 and returns a truth value indicating that 2 is less than 3. But the expression (<3) returns a box which contains the array 3. While the details here are a bit different, the general concepts should be familiar to users of other programming languages. (For example, in C, 2&3 performs a bitwise and between the two numbers, and &y returns a pointer to the value referred to by y.)