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

13
LINES

< > BotCompany Repo | #1023874 // minOfIntArray_withIndex

JavaX fragment (include)

// return index and value
static Pair<Int> minOfIntArray_withIndex(int[] a) {
  if (a == null || a.length == 0) null;
  int n = a.length, x = a[0], best = 0;
  for (int i = 1; i < n; i++) {
    int y = a[i];
    if (y < x) {
      x = y;
      best = i;
    }
  }
  ret pair(best, x);
}

Author comment

Began life as a copy of #1023863

download  show line numbers  debug dex  old transpilations   

Travelled to 6 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1023874
Snippet name: minOfIntArray_withIndex
Eternal ID of this version: #1023874/2
Text MD5: 51fec3a7b05db7c3a154a1c97dff2439
Author: stefan
Category: javax / maths
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-07-11 00:06:58
Source code size: 298 bytes / 13 lines
Pitched / IR pitched: No / No
Views / Downloads: 237 / 247
Version history: 1 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)