Category talk:Wren-seq: Difference between revisions
Content added Content deleted
(→Source code: Added Lst.reverse and Lst.removeBy, removed Lst.toMap (going to new MapUtil module).) |
(→Source code: Added Lst.areEqual method.) |
||
Line 471: | Line 471: | ||
// Returns true if all elements of a list are the same, false otherwise. |
// Returns true if all elements of a list are the same, false otherwise. |
||
static allSame(a) { distinct(a).count == 1 } |
static allSame(a) { distinct(a).count == 1 } |
||
// Returns whether two lists a, b are the same length |
|||
// and contain 'equal' elements (using the '==' operator) |
|||
// in the same order. |
|||
static areEqual(a, b) { |
|||
isList_(a) |
|||
isList_(b) |
|||
if (a == b) return true |
|||
var ac = a.count |
|||
var bc = b.count |
|||
if (ac != bc) return false |
|||
for (i in 0...ac) { |
|||
if (a[i] != b[i]) return false |
|||
} |
|||
return true |
|||
} |
|||
// Splits a list into chunks of not more than 'size' elements. |
// Splits a list into chunks of not more than 'size' elements. |