Category talk:Wren-seq: Difference between revisions
Content added Content deleted
(Added source code for new 'Wren-seq' module.) |
(→Source code: Lst.indicesOf should return a list of 3 arguments, not 2.) |
||
Line 59: | Line 59: | ||
var count = a.count |
var count = a.count |
||
var indices = [] |
var indices = [] |
||
if (count == 0) return [false, indices] |
if (count == 0) return [false, 0, indices] |
||
if (start >= 0) { |
if (start >= 0) { |
||
if (start >= count) return [false, indices] |
if (start >= count) return [false, 0, indices] |
||
for (i in start...count) { |
for (i in start...count) { |
||
if (a[i] == value) indices.add(i) |
if (a[i] == value) indices.add(i) |
||
Line 67: | Line 67: | ||
} else { |
} else { |
||
start = count + start |
start = count + start |
||
if (start < 0) return [false, indices] |
if (start < 0) return [false, 0, indices] |
||
for (i in start..0) { |
for (i in start..0) { |
||
if (a[i] == value) indices.add(i) |
if (a[i] == value) indices.add(i) |
||
} |
} |
||
} |
} |
||
if (indices.isEmpty) return [false, indices] |
if (indices.isEmpty) return [false, 0, indices] |
||
return [true, indices] |
return [true, indices.count, indices] |
||
} |
} |
||