2

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?

Quotient does the job! – Ali – 2013-05-27T15:28:22.047

Since everybody's going nuts with alternative solutions: one could also use

`Fold[]`

+`Riffle[]`

for the task... – J. M.'s ennui – 2013-05-28T04:16:10.733