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

36
LINES

< > BotCompany Repo | #1026917 // toDoubleArray

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

Transpiled version (136L) is out of date.

static double[] toDoubleArray(Cl<Double> l) {
  double[] a = new double[l(l)];
  int i = 0;
  if (a.length != 0) for (double x : l)
    a[i++] = x;
  ret a;
}

ifclass IntBuffer
static double[] toDoubleArray(IntBuffer b) {
  int n = l(b);
  double[] a = new [n];
  for i to n:
    a[i] = b.get(i);
  ret a;
}
endif

meta-for float also as int {
  static double[] toDoubleArray(float... l) {
    double[] a = new[l(l)];
    for (int i = 0; i < a.length; i++)
      a[i] = l[i];
    ret a;
  }
}

ifclass IDoubleBuffer
static double[] toDoubleArray(IDoubleBuffer b) {
  int n = l(b);
  double[] a = new [n];
  for i to n:
    a[i] = b.get(i);
  ret a;
}
endif

Author comment

Began life as a copy of #1004992

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: #1026917
Snippet name: toDoubleArray
Eternal ID of this version: #1026917/9
Text MD5: 0d82b087fac470846ab581b7f88f0120
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-12-15 23:28:43
Source code size: 692 bytes / 36 lines
Pitched / IR pitched: No / No
Views / Downloads: 321 / 448
Version history: 8 change(s)
Referenced in: [show references]