Comparison: Difference between revisions

From The K Language Wiki
Content added Content deleted
(add comparison page)
 
("Better category ordering, add redirects to categories, fix pseudo-adverb categories")
 
(8 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{primitive|x&lt;y<br>x&gt;y}}
{{primitive|x&lt;y<br>x&gt;y<br>x&#61;y}}


The comparison primitives in K are <code><</code> and <code>></code> which stand for lesser and greater than respectively.
The comparison primitives in K are <code><</code>, <code>></code> and <code>=</code> which stand for lesser than, greater than and equal to respectively. Comparisons are [[atomicity|fully atomic]].


Characters are compared as bytes, except in oK which supports Unicode and compares characters by their code points.
character comparison is done via ASCII codes/UTF-8 code points, based on the implementation.


The comparison functions always give a boolean value, 1 or 0.
The comparison functions always give a boolean value, 1 or 0.
Line 13: Line 13:
"abc" > "!c "
"abc" > "!c "
1 0 1
1 0 1

2 56 1 = (2;4;"a")
1 0 0
</pre>
</pre>

[[Category:Verbs]]
[[Category:Operator verbs]]
[[Category:Primitives]]

Latest revision as of 06:14, 9 July 2022

Comparison
x<y
x>y
x=y

The comparison primitives in K are <, > and = which stand for lesser than, greater than and equal to respectively. Comparisons are fully atomic.

Characters are compared as bytes, except in oK which supports Unicode and compares characters by their code points.

The comparison functions always give a boolean value, 1 or 0.

 1 2 3 < 3 1 5
1 0 1

 "abc" > "!c "
1 0 1

 2 56 1 = (2;4;"a")
1 0 0