Jump to content

Talk:Ternary operation: Difference between revisions

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia
Content deleted Content added
LarsPM (talk | contribs)
m fixed typo
Vbakke (talk | contribs)
Line 51: Line 51:


[[Azarien]] merged a couple of the examples yesterday. [[User:Xertoz|Xertoz]] ([[User talk:Xertoz|talk]]) 12:52, 21 February 2010 (UTC)
[[Azarien]] merged a couple of the examples yesterday. [[User:Xertoz|Xertoz]] ([[User talk:Xertoz|talk]]) 12:52, 21 February 2010 (UTC)

== Remove examples? ==
As the first section states, the ?: operator is just one kind of ternary operators. Why do we have a verbose list of only ''one'' of the ternary operators? This list should be moved to the ternary conditional operator.

As examples we should list the different types instead, such as ?: in many programming languages, and maybe SQL ''BETWEEN AND'' as another (Value1 BETWEEN Value2 AND Value3).
--[[User:Vbakke|Vbakke]] ([[User talk:Vbakke|talk]]) 21:22, 30 August 2011 (UTC)


== a,b ==
== a,b ==

Revision as of 21:22, 30 August 2011

WikiProject iconC/C++ Start‑class Mid‑importance
WikiProject iconThis article is within the scope of WikiProject C/C++, a collaborative effort to improve the coverage of C and C++ topics on Wikipedia. If you would like to participate, please visit the project page, where you can join the discussion and see a list of open tasks.
StartThis article has been rated as Start-class on Wikipedia's content assessment scale.
MidThis article has been rated as Mid-importance on the importance scale.
WikiProject iconComputing Start‑class Mid‑importance
WikiProject iconThis article is within the scope of WikiProject Computing, a collaborative effort to improve the coverage of computers, computing, and information technology on Wikipedia. If you would like to participate, please visit the project page, where you can join the discussion and see a list of open tasks.
StartThis article has been rated as Start-class on Wikipedia's content assessment scale.
MidThis article has been rated as Mid-importance on the project's importance scale.

Why is ternary operation sharing a page with ternary operator? Although similar and related concepts, they are not exactly the same. A ternary operation in mathematics maps . Whereas a ternary operator is just something that takes three arguments. A vector triple product is an example of a ternary operator but it is not a ternary operation, since it takes three vectors and gives a scalar result.

I would propose separating the two pages with links from each pointing toward the other for people who find themselves in the wrong place.--Hawthorn 13:37, 16 August 2006 (UTC)[reply]

PHP?

Is this the same as in PHP : $int = ($ifstatement) ? $thenvalue : $elsevalue;

Yes. See ?:. –EdC 23:00, 26 February 2007 (UTC)[reply]

Citation

Where is the citation [1], for "ternary" instead of "tertiary".Naveen Kumar Molleti (talk) 13:13, 20 June 2008 (UTC)Nav11aug[reply]

Agreed. I originally made the edit to tertiary being a proper use, and do not agree with its invalidity. The citation given (which does not show up properly in wiki, I assume because of the colon in the url, and cannot be reached on the webserver that hosts it [had to use google cache]) itself gives no real proof. If I do not see a proper citation on this soon I will revert the edit, as I believe my citation (Microsoft) to be a more valid reference than a random guy on a forum. Dakusan (talk) 08:38, 7 January 2009 (UTC)[reply]
Thirded. The reference only says that "tertiary" is incorrect without reason. Ternary is clearly correct by extension of unary, binary, etc. IMO, "tertiary" is not wrong: it means third order, which is a perfectly acceptable thing to call it. You wouldn't say "secondary" because that could mean "of lesser importance", but you might say "second order". Kjsharke (talk) 17:57, 19 May 2009 (UTC)[reply]

External Link

I have deleted the following external link recently added by User:Boolean hexadecimal. It links only to a diagram on a flickr page. The diagram is completely devoid of explanation and its relevance to the article is very unclear. External links should be to authoritative sources of further information. This flickr page diagram isn't either.

Hawthorn (talk) 21:40, 25 March 2009 (UTC)[reply]


Hi. The octeract graph is just the introducing image to this page. Below there is a list of hexadecimal numbers, linking to diagrams of ternary Boolean operations, like 01 (the conjunctions), 7F (the disjunctions), or 16, showing the minimal negation operator. 17 is a very special operator, but seems to be nameless.
You don't see the connection with the octeract graph? Just look in the bottom right corner of the linked diagrams.
Greetings, Boolean hexadecimal (talk) 16:23, 27 March 2009 (UTC)[reply]

PHP?

An example in PHP but not

Is there a name for this?

I see several other ternary operators, such as ?:, have articles, so I'm wondering if there's a name for this one or a category it falls under:

A Chinese language corpus I use (corpus here, documentation here, but they will only display properly in IE) has several ternary operators for searching, they basically do the same thing as regex but through operators such as $, +, -, etc. For instance,

中$5国

means "all results where comes before and they are separated by 5 or fewer characters"—so 中, 5, and 国 are its arguments. Does anyone know if there's a name for ternary operators like this? rʨanaɢ talk/contribs 23:35, 24 September 2009 (UTC)[reply]

C

There's little information about the ternary in C. Although the header references to the C syntax, there's no information on wether it's C99 etc and there is no example showing C code. Would someone with proper knowledge fix this? Xertoz (talk) 14:48, 23 October 2009 (UTC)[reply]

Added an example showing C code and referenced it. Xertoz (talk) 13:16, 1 December 2009 (UTC)[reply]

Excessive examples?

The C, C#, Java, and Javascript examples are completely 100% identical to each other. The Perl and PHP are also the same functionally, but just add the sigils those languages require. These excessive examples add absolutely nothing to helping understand what a ternary operation is. One example in a C-like language would be fine. 128.205.70.161 (talk) 18:23, 18 February 2010 (UTC)[reply]

Azarien merged a couple of the examples yesterday. Xertoz (talk) 12:52, 21 February 2010 (UTC)[reply]

Remove examples?

As the first section states, the ?: operator is just one kind of ternary operators. Why do we have a verbose list of only one of the ternary operators? This list should be moved to the ternary conditional operator.

As examples we should list the different types instead, such as ?: in many programming languages, and maybe SQL BETWEEN AND as another (Value1 BETWEEN Value2 AND Value3). --Vbakke (talk) 21:22, 30 August 2011 (UTC)[reply]

a,b

I understand the point but doesn't the use of only two things a and b fog the issue.

Shouldn't the distiction be something like X if Y else Z

or

if Y result = X else Z.

The use of two variables a and b is also equivalent to asking for the max(a,b) if a language supported it. That is not the spirit of the topic. The spirit is if a>b there is a value returned and if not a different value. In fact the comparison used (a>b) confuses the issue as well. It should be a simple if true/false not necessarily a greater than. It need only be a boolean. —Preceding unsigned comment added by 129.170.107.121 (talk) 21:19, 6 May 2010 (UTC)[reply]

Python comparison operators

Where one in many other languages would write something like a < b && b < c, Python lets you write a < b < c. As is explained in Python syntax and semantics#Comparison operators, the Python expression can't be considered as just a shorthand for the expanded version, so it is a ternary operator. Maybe we should add it as an example.