More lib files, more functional
Still missing that 'attack' fn, though :(
This commit is contained in:
10
lib/reducers.ts
Normal file
10
lib/reducers.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
export const pipe = (...fns) => (input) =>
|
||||
fns.reduce((acc, fn) => fn(acc), input);
|
||||
|
||||
export const redFn = (acc, x) => [...acc, x];
|
||||
|
||||
export const mapR = (fn) => (input) =>
|
||||
input.reduce((acc, x) => [...acc, fn(x)], []);
|
||||
|
||||
export const filterR = (pred) => (input) =>
|
||||
input.reduce((acc, x) => pred(x) ? [...acc, x] : acc ,[]);
|
Reference in New Issue
Block a user