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.

1  
static double[] toDoubleArray(Cl<Double> l) {
2  
  double[] a = new double[l(l)];
3  
  int i = 0;
4  
  if (a.length != 0) for (double x : l)
5  
    a[i++] = x;
6  
  ret a;
7  
}
8  
9  
ifclass IntBuffer
10  
static double[] toDoubleArray(IntBuffer b) {
11  
  int n = l(b);
12  
  double[] a = new [n];
13  
  for i to n:
14  
    a[i] = b.get(i);
15  
  ret a;
16  
}
17  
endif
18  
19  
meta-for float also as int {
20  
  static double[] toDoubleArray(float... l) {
21  
    double[] a = new[l(l)];
22  
    for (int i = 0; i < a.length; i++)
23  
      a[i] = l[i];
24  
    ret a;
25  
  }
26  
}
27  
28  
ifclass IDoubleBuffer
29  
static double[] toDoubleArray(IDoubleBuffer b) {
30  
  int n = l(b);
31  
  double[] a = new [n];
32  
  for i to n:
33  
    a[i] = b.get(i);
34  
  ret a;
35  
}
36  
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: 308 / 436
Version history: 8 change(s)
Referenced in: [show references]