Ternary operation

1

In mathematics, a ternary operation is an n-ary operation with n = 3. A ternary operation on a set A takes any given three elements of A and combines them to form a single element of A. In computer science, a ternary operator is an operator that takes three arguments as input and returns one output.

Examples

The function is an example of a ternary operation on the integers (or on any structure where + and \times are both defined). Properties of this ternary operation have been used to define planar ternary rings in the foundations of projective geometry. In the Euclidean plane with points a, b, c referred to an origin, the ternary operation has been used to define free vectors. Since (abc) = d implies a – b = c – d, these directed segments are equipollent and are associated with the same free vector. Any three points in the plane a, b, c thus determine a parallelogram with d at the fourth vertex. In projective geometry, the process of finding a projective harmonic conjugate is a ternary operation on three points. In the diagram, points A, B and P determine point V, the harmonic conjugate of P with respect to A and B. Point R and the line through P can be selected arbitrarily, determining C and D. Drawing AC and BD produces the intersection Q, and RQ then yields V. Suppose A and B are given sets and is the collection of binary relations between A and B. Composition of relations is always defined when A = B, but otherwise a ternary composition can be defined by where q^T is the converse relation of q. Properties of this ternary relation have been used to set the axioms for a heap. In Boolean algebra, defines the formula.

Computer science

In computer science, a ternary operator is an operator that takes three arguments (or operands). The arguments and result can be of different types. Many programming languages that use C-like syntax feature a ternary operator,, which defines a conditional expression. In some languages, this operator is referred to as the conditional operator. In Python, the ternary conditional operator reads. Python also supports ternary operations called array slicing, e.g. return an array where the first element is and last element is. OCaml expressions provide ternary operations against records, arrays, and strings: would mean the string where index has value. The multiply–accumulate operation is another ternary operator. Another example of a ternary operator is between, as used in SQL. The Icon programming language has a "to-by" ternary operator: the expression generates the odd integers from 1 through 9. In Excel formulae, the form is =if(C, x, y).

This article is derived from Wikipedia and licensed under CC BY-SA 4.0. View the original article.

Wikipedia® is a registered trademark of the Wikimedia Foundation, Inc.
Bliptext is not affiliated with or endorsed by Wikipedia or the Wikimedia Foundation.

Edit article