repeat fn
This commit is contained in:
parent
f20cf6841a
commit
8d6a3fc45b
1 changed files with 10 additions and 0 deletions
|
@ -142,3 +142,13 @@ export const reduce = curry(dispatch(['fantasy-land/reduce', 'reduce'],
|
||||||
(f, acc, xs) => xs.reduce(f, acc)
|
(f, acc, xs) => xs.reduce(f, acc)
|
||||||
))
|
))
|
||||||
|
|
||||||
|
export const repeat = curry((n, f) => {
|
||||||
|
const results = []
|
||||||
|
|
||||||
|
for (let i = n; i > 0; i--) {
|
||||||
|
results.push(f())
|
||||||
|
}
|
||||||
|
|
||||||
|
return results
|
||||||
|
})
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue