What would be the best way to achieve this using Ramda.js?
function innerVals(array) {
const lengthMinus1 = array.length - 1;
return array.slice(1, lengthMinus1);
}
I cannot seem to find a good way to slice until length - 1 without storing that variable somewhere. The best I could come up with is using Ramda's converge function like this:
// innerVals :: Array -> Array
function innerVals(array) {
// lengthMinus1 :: Array -> Number
const lengthMinus1 = R.pipe(R.length, R.subtract(_, 1));
// getVals :: Array -> Array
const getVals = R.converge(
R.slice(1, _, _),
[lengthMinus1, R.identity]
);
return getVals(array);
}
I'm having a difficult time believing that this is a clean way to accomplish such a simple goal. There's significantly more code in the functional programming approach, and I also think it would be more difficult for other developers to read / maintain. Am I missing something? If anyone has a different approach, please let me know. Thanks!