repeat fn

This commit is contained in:
Rowan 2025-04-17 12:54:36 -05:00
parent f20cf6841a
commit 8d6a3fc45b

View file

@ -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
})