I am trying to implement SparseArray, using the function With to give the condition for different matrix elements. I would need a function f, that instead of doing what Mod does,
Mod[{1, 2, 3, 4, 5, 6}, 3, 1]
{1, 2, 3, 1, 2, 3}
I would like to have:
f[{1, 2, 3, 4, 5, 6}, 3, 1]
{1, 1, 1, 2, 2, 2}
So that,
f[1,3,1]
1
and
f[4,3,1]
2
Does such a function f exist?
Fold[]+Riffle[]for the task... – J. M.'s missing motivation May 28 '13 at 04:16