Libraryless. Click here for Pure Java version (127L/1K).
static L<Int> localMaxima(L<Double> l) { ret localMaxima(toDoubleArray(l)); } static L<Int> localMaxima(double[] l) { new L<Int> out; int n = l(l); for i to n: if ((i == 0 || l[i] > l[i-1]) && (i == n-1 || l[i] > l[i+1])) out.add(i); ret out; }
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: | #1025236 |
Snippet name: | localMaxima - note: does not find a maximum when there is a plateau |
Eternal ID of this version: | #1025236/3 |
Text MD5: | 37ba76d19e8a57d17b08fa116cd830b7 |
Transpilation MD5: | ecb2c061ab22590f599b38f70753dead |
Author: | stefan |
Category: | javax / maths |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2022-04-28 20:29:06 |
Source code size: | 283 bytes / 13 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 215 / 313 |
Version history: | 2 change(s) |
Referenced in: | [show references] |