I have a function that takes in sequences of values (as a list), and recursively removes the largest element from that sequence as part of its computation. Some of these sequences can be quite large, but I suspect that they often have common subsequences. So I want to memoize my function, but I don't want to memoize it for very large sequences, only smaller sequences which these larger sequences might have in common. I tried something like this,
f[sequence_?Length[#] < 16 &] := f[sequence] = f[sequence]
f is already defined elsewhere. Probably I would need to memoize for larger sequences, but that's the idea of it. However, I hit the recursion limit when I call this function.