mirror of
https://github.com/TangentFoxy/lume.git
synced 2025-07-28 11:02:20 +00:00
Added lume.each() function
This commit is contained in:
10
README.md
10
README.md
@@ -70,6 +70,15 @@ Iterates the supplied iterator and returns an array filled with the values.
|
||||
lume.array(pairs({a = 1, b = 2})) -- Returns {"a", "b"}
|
||||
```
|
||||
|
||||
### lume.each(t, fn, ...)
|
||||
Iterates the table `t` and calls the function `fn` on each value followed by
|
||||
the supplied additional arguments; if `fn` is a string the method of that name
|
||||
is called for each value. The function returns `t` unmodified.
|
||||
```lua
|
||||
lume.each({1, 2, 3}, print) -- Prints "1", "2", "3" on separate lines
|
||||
lume.each({a, b, c}, "move", 10, 20) -- Does x:move(10, 20) on each value
|
||||
```
|
||||
|
||||
### lume.map(t, fn)
|
||||
Applies the function `fn` to each value in table `t` and returns a new table
|
||||
with the resulting values.
|
||||
@@ -132,7 +141,6 @@ exist in the table.
|
||||
lume.find({"a", "b", "c"}, "b") -- Returns 2
|
||||
```
|
||||
|
||||
|
||||
### lume.slice(t [, i [, j]])
|
||||
Mimics the behaviour of Lua's `string.sub`, but operates on an array rather
|
||||
than a string. Creates and returns a new array of the given slice.
|
||||
|
Reference in New Issue
Block a user