Example 1 — Official One-Argument Method
Turn slice into a function that takes the start index, then the string.
const sliceFrom = R.invoker(1, "slice");
console.log(sliceFrom(6, "abcdefghijklm"));
// → "ghijklm"
console.log(sliceFrom(6)("abcdefghijklm"));
// → "ghijklm" How It Works
- Arity 1.
slicegets one argument here (the start), so the result waits for 1 + 1 = 2 arguments. - Target last.
6goes toslice; the string is the object it runs on. - Same call. It runs
"abcdefghijklm".slice(6)→"ghijklm". - Curried.
sliceFrom(6)("…")gives the same answer, one argument at a time.
