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

22
LINES

< > BotCompany Repo | #1029079 // intArray_minus

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

Libraryless. Click here for Pure Java version (9208L/51K).

static int[] intArray_minus(int[] array, int x) {
  if (x == 0 || empty(array)) ret array;
  int n = array.length;
  int[] b = new[n];
  for i to n:
    b[i] = array[i]-x;
  ret b;
}

static int[] intArray_minus(int x, int[] array) {
  ret intArray_minus(array, x);
}

static int[] intArray_minus(int[] array1, int[] array2) {
  int n = l(array1);
  if (l(array2) != n) fail("Need same size");
  if (n == 0) ret array1;
  int[] b = new[n];
  for i to n:
    b[i] = array1[i]-array2[i];
  ret b;
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1029079
Snippet name: intArray_minus
Eternal ID of this version: #1029079/3
Text MD5: 4712f243d2a6635009c15e91c3d4640b
Transpilation MD5: 4cf96e0456889ca72c664987d4e82aa8
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-08-05 16:09:25
Source code size: 519 bytes / 22 lines
Pitched / IR pitched: No / No
Views / Downloads: 122 / 198
Version history: 2 change(s)
Referenced in: [show references]