Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

7
LINES

< > BotCompany Repo | #1030510 // sortedPair - make sure that a <= b

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (122L/1K).

static <A> Pair<A> sortedPair(A a, A b) {
  ret cmp(a, b) <= 0 ? pair(a, b) : pair(b, a);
}

static <A> Pair<A> sortedPair(Pair<A> p) {
  ret p == null ?: cmp(p.a, p.b) <= 0 ? p : reversePair(p);
}

download  show line numbers  debug dex  old transpilations   

Travelled to 4 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, vouqrxazstgt

No comments. add comment

Snippet ID: #1030510
Snippet name: sortedPair - make sure that a <= b
Eternal ID of this version: #1030510/5
Text MD5: d97d767d25ffa1fd28b11b1121fb1416
Transpilation MD5: 2ec1f1a58560cc468b1aabee5be63c3c
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-01-03 22:11:52
Source code size: 203 bytes / 7 lines
Pitched / IR pitched: No / No
Views / Downloads: 178 / 258
Version history: 4 change(s)
Referenced in: [show references]