i new selectors. have created following ones: import { createselector } 'reselect'; const getvalues = (state) => state.grid; // [3, 4, 7, 3, 2, 7, 3,...] const gettiles = (state) => state.tiles; // [0, 1, 0, 1, 0, 0, 1,...] // counts selected tiles (ie. adds 1s) export const getselected = createselector( [gettiles], tiles => tiles.reduce((acc, elem) => acc + elem, 0) ); // displays values of selected tiles, rest shows 0 export const showselected = createselector( [gettiles, getvalues], (tiles, grid) => tiles.map((idx, i) => (idx === 1 ? grid[i] : 0)) ); export const addselected = createselector( [showselected] ..... ); /* export const addselected = createselector( [showselected], coun => coun.reduce((acc, elem) => acc + elem, 0) ); */ the third selector (addselected - last bottom, commented-out version) same thing first 1 (with different inputs). how can make more generic can reuse instead of writing whole 'reduce...