> Write a dfn that takes a character vector as its right argument and k (the substring length) as its left argument and returns a vector of the k-mers of the original string.
Now, the core solution is very easy. The real problem here is handling the edge cases where k is larger than the length of the vector.
But you can actually use any character, because the outer array is empty, so there'll only be the prototype, and that's always made of spaces for character arrays and zeros for numeric arrays.
That said, why not make the function more generally applicable? Let's allow numeric "DNA" too? How might we get a prototype that matches the argument type?
That's a possibility, but better to only extend if needed.
There's also a minor thing that if the left argument is 1 then we'll do ,/ over length-one subvectors, which gives us a simple scalar, so the result becomes a vector of scalars (i.e. a simple vector) rather than a vector of vectors. But I'll leave that alone.