Elm Exactly

Figuredynamic-basis-order

Figure 55, Order of Comparable Values, in Section D.4.6 Order.

  1. Int values mm, nn: cmp(m,n)\dbcmp(m,n) is LT if m<nm<n, EQ if m=nm=n, and GT if m>nm>n.

  2. Floats xx, yy: cmp(x,y)\dbcmp(x,y) is EQ if both are NaN, GT if only xx is NaN, LT if only yy is NaN, and otherwise LT, EQ or GT as x<yx<y, x=yx=y or x>yx>y.

  3. Characters: cmp(ch,ch′)=cmp(code(ch),code(ch′))\dbcmp(\dbch,\dbch')=\dbcmp(\dbcode(\dbch),\dbcode(\dbch')).

  4. Strings s=ch1⋯chks=\dbch_1\cdots\dbch_k and s′=ch1′⋯chl′s'=\dbch'_1\cdots\dbch'_l: if chi≠chi′\dbch_i\neq\dbch'_i for some i≤min⁡(k,l)i\leq\min(k,l), and ii is the least such, then cmp(s,s′)=cmp(chi,chi′)\dbcmp(s,s')=\dbcmp(\dbch_i,\dbch'_i); otherwise cmp(s,s′)=cmp(k,l)\dbcmp(s,s')=\dbcmp(k,l).

  5. Lists: cmp([],[])=EQ\dbcmp(\kw{[]},\kw{[]})=\kw{EQ}, cmp([],v1::v2)=LT\dbcmp(\kw{[]},v_1\mathbin{\kw{::}}v_2)=\kw{LT}, cmp(v1::v2,[])=GT\dbcmp(v_1\mathbin{\kw{::}}v_2,\kw{[]})=\kw{GT}, and cmp(v1::v2, v1′::v2′)\dbcmp(v_1\mathbin{\kw{::}}v_2,\,v'_1\mathbin{\kw{::}}v'_2) is cmp(v1,v1′)\dbcmp(v_1,v'_1) if that is not EQ, and cmp(v2,v2′)\dbcmp(v_2,v'_2) otherwise.

  6. Tuples (v1,…,vk)(v_1,\ldots,v_k) and (v1′,…,vk′)(v'_1,\ldots,v'_k): cmp(vi,vi′)\dbcmp(v_i,v'_i) for the least ii with cmp(vi,vi′)≠EQ\dbcmp(v_i,v'_i)\neq\kw{EQ}, and EQ if there is none.

Figure 55: Order of Comparable Values
Read it in its chapter·Permanent address: /standard/figures/dynamic-basis-order

Referred to from

Tests (0)

No test of the suite checks this figure yet.

Discussions

Discuss this figure·Search the discussions on GitHub

Discussions are on GitHub; one about this figure has [fig:dynamic-basis-order] in its title.

A Standard Definition of Elm? (Draft version 0.4) © Rupert Smith. The text is licensed under CC BY 4.0: share and adapt it freely, with credit and a link to the licence.