Added isarray argument to lume.set

This commit is contained in:
rxi
2014-02-27 22:17:36 +00:00
parent 2636035974
commit eeadcd307d
2 changed files with 18 additions and 15 deletions

View File

@@ -80,12 +80,6 @@ calls to `fn` return true.
lume.all({1, 2, 1}, function(x) return x == 1 end) -- Returns true
```
### lume.set(t)
Returns a copy of the array `t` with all the duplicate values removed.
```lua
lume.set({2, 1, 2, "cat", "cat"}) -- Returns {1, 2, cat}
```
### lume.reduce(t, fn [, first])
Applies `fn` on two arguments cumulative to the items of the array `t`, from
left to right, so as to reduce the array to a single value. If the `first`
@@ -94,6 +88,13 @@ argument is not supplied the accumulator is initialised to `0`.
lume.reduce({1, 2, 3}, function(a, b) return a + b end) -- Returns 6
```
### lume.set(t, [, isarray])
Returns a copy of the `t` table with all the duplicate values removed. If
`isarray` is true the table is treated as an array.
```lua
lume.set({2, 1, 2, "cat", "cat"}) -- Returns {1, 2, cat}
```
### lume.filter(t, fn [, isarray])
Iterates the table `t` and calls `fn` on each value. Returns a new table with
only the value which `fn` returned true. If `isarray` is true the table is