Rank (J programming language)

Rank (J programming language)

Rank in the J programming language has several different meanings.

; Noun rank : The rank of a noun is a non-negative integer.; Verb rank : The rank of a verb is a list of three integers. ; The rank conjunction : The rank conjunction (") is used to derive a verb with a specific rank.

Noun rank

Nouns, in J, are arrays. The rank of a noun is the number of dimensions of that array. The derived verb "#@$" determines the rank of a noun.

Verb rank

Verbs, in J, are functions which take noun arguments and produce noun results. The rank of a verb controls how the verb is applied to nouns with ranks greater than 0. This verb rank is expressed as three numbers:

# Rank for the monad case
# Rank for the left argument for the dyad case
# Rank for the right argument for the dyad case

In all cases, there is some underlying verb definition which applies to cells -- which is to say, sub-arrays of the indicated rank. Or, if the argument doesn't have that many dimensions, the entire argument.

In verbs, negative rank is interpreted as the rank of the noun supplied for that argument less the indicated value. (But never less than zero.)

: For example, a verb with monadic rank of -1 when given an argument of rank 3, breaks the argument down into a list of rank 2 arrays. The verb's body is applied once to each of these 2-dimensional sub-arrays.

In the context of a specific verb and a specific noun, the dimensions of that noun are divided into a set of prefix dimensions, called the frame, and a set of suffix dimensions, called the cells. Positive verb ranks indicate the number of cell dimensions, negative verb ranks indicate the number of frame dimensions.

In the dyadic case, there are two frames -- one for the left argument, and one for the right argument. These frames must agree. Which is to say if the frames are not identical, one must be a suffix of the other. The result of evaluating this verb will have the dimensions of the longest frame as the prefix dimensions of its result. (Trailing result dimensions, if any, would come from the verb's body.)

For example

10 + 4 5 6 14 15 16

Here, the verb + has a rank of 0 0 0, the left argument has a rank of 0, and the right argument has a rank of 1 (with a dimension of 3). Thus, the left argument has a rank 0 frame and the right argument has a rank 1 frame (with a dimension 3). The left argument's (empty) frame is a valid suffix for the right argument's frame, so this is a valid operation. The result has a rank of 1 and a dimension of 3.

The rank conjunction

The rank conjunction takes a verb left argument and creates a new verb using that as the body of the verb. The right argument specifies the rank of this derived verb.

If the right argument is only two numbers, they are taken as the ranks for the dyadic case, and the second number is used for the monadic case.

If the right argument is only one number, it is taken as the rank for all three cases.

If the right argument is a verb, its rank is used.

: For example, these all derive the same verb:
* +"0 0 0
* +"0 0
* +"0
* +"+

If the left argument to the rank conjunction is a noun, a constant verb is created. The body of this verb ignores the values of any arguments and always produces a result which is that noun.

External links

* [http://jsoftware.com/help/dictionary/intro20.htm|J Dictionary entry for "rank"]
* [http://jsoftware.com/help/learning/07.htm|Rank in "Learning J"]


Wikimedia Foundation. 2010.

Игры ⚽ Нужно сделать НИР?

Look at other dictionaries:

  • Rank (computer programming) — In computer programming, rank with no further specifications is usually a synonym for (or refers to) number of dimensions ; thus, for instance, a bi dimensional array has rank two , a three dimensional array has rank three and so on.Strictly, no… …   Wikipedia

  • MAD (programming language) — MAD Paradigm(s) Imperative Appeared in 1959 Developer Galler, Arden, and Graham Major implementations IBM 704, IBM 7090, UNIVAC 1108, Philco 210 211, IBM S/360, and IBM S/370 …   Wikipedia

  • J (programming language) — Not to be confused with the J++ or J# programming languages. Infobox programming language name = J paradigm = array, functional, function level, tacit year = 1990 designer = Ken Iverson Roger Hui developer = JSoftware latest release version =… …   Wikipedia

  • Criticism of the APL programming language — The APL programming language has been used since the mid 1960s on mainframe computers and has itself evolved in step with computers and the computing market. APL is not widely used, but minimalistic and high level by design, at several points in… …   Wikipedia

  • UNITY (programming language) — The UNITY programming language was constructed by K. Mani Chandy and Jayadev Misra for their book Parallel Program Design: A Foundation . It is a rather theoretical language, which tries to focus on what , instead of where , when or how . The… …   Wikipedia

  • Language — This article is about the properties of language in general. For other uses, see Language (disambiguation). Cuneiform is one of the first known forms of written language, but spoken language is believed to predate writing by tens of thousands of… …   Wikipedia

  • Array programming — In computer science, array programming languages (also known as vector or multidimensional languages) generalize operations on scalars to apply transparently to vectors, matrices, and higher dimensional arrays.Array programming primitives… …   Wikipedia

  • Dynamic programming — For the programming paradigm, see Dynamic programming language. In mathematics and computer science, dynamic programming is a method for solving complex problems by breaking them down into simpler subproblems. It is applicable to problems… …   Wikipedia

  • Linear programming — (LP, or linear optimization) is a mathematical method for determining a way to achieve the best outcome (such as maximum profit or lowest cost) in a given mathematical model for some list of requirements represented as linear relationships.… …   Wikipedia

  • DOT language — DOT is a plain text graph description language. It is a simple way of describing graphs that both humans and computer programs can use. DOT graphs are typically files that end with the .gv (or .dot) extension. The .gv extension is preferred, as… …   Wikipedia

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”