in reply to index of the minimum element of the array
Use python:
a = [1, 2, -17, 99] min_idx = a.index(min(a))
Or ruby:
a = [1, 2, -17, 99] min_idx = a.index(a.min)
;-)
Update: Momentary confusion javascript/ruby. Corrected. Thanks, LanX.
This is the JS example I intended to supply:
var a = [1, 2, -17, 99]; var min_idx = a.indexOf(Math.min.apply(Math, a));
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: index of the minimum element of the array
by dcmertens (Scribe) on Jan 18, 2014 at 03:55 UTC | |
|
Re^2: index of the minimum element of the array
by LanX (Saint) on Jan 17, 2014 at 19:22 UTC |