I'm trying to use the modulo operator and it is not working.

```
n "0 .. 12" |* n "5" |% n "12"
```

Raises the exception "No instance for (Real ValueMap) arising from a use of ‘|%’".

Is this a bug or am I missing something?

I'm trying to use the modulo operator and it is not working.

```
n "0 .. 12" |* n "5" |% n "12"
```

Raises the exception "No instance for (Real ValueMap) arising from a use of ‘|%’".

Is this a bug or am I missing something?

I'm not aware of this being a valid operator in tidal - it's def not working in minitidal (all I can test with here)

Is something like this what you're after?

```
n "{1 2 3 4}%12"
# s "sprvibe"
|* n "12"
```

The modulo operator appears in the documentation

I didn't try in minitidal but in tidalcycles.

What you suggest is not what I'm looking for.

I will defer to the experts

PS that page looks like it could do with some significant cleanup...

I agree. These pages were formatted using tables on the old wiki and it's really a pain to format them the same way using MarkDown. We will have to figure out some new way to present this information in a more simple and beginner-friendly way. I can't say more about the modulo operator because I've never used it.

1 Like

**Disclaimer** I think there is a bug with the modulo operator, but there is a workaround for using it right now.

@ShaiR I used this modulo operator sometimes for an easy way to create chord inversions with patterns or limiting the amount of possible values. You can apply the modulo on the pattern itself, but not on the result of the n function:

```
-- Direct calculation on the pattern
n ("0 .. 12" |* 5 |% 12)
```

But indeed you can calculate something and combine it with an other pattern result:

```
n ("0 .. 12" |* 5 |% 12) |+ n "5"
```

And yes in the mininotation the modulo operator has a different meaning

```
-- This maps the {1 2 3 4} to 12 events within a cycle
n ("{1 2 3 4}%12" )
```

As I mentioned in the beginning, I guess there is a bug with modulo:

```
-- These type signatures are the same
(|*) :: Num a => Pattern a -> Pattern a -> Pattern a
(|%) :: Real a => Pattern a -> Pattern a -> Pattern a
-- When I can do this:
n ("0 .. 12") |* n "4"
-- I should do this too:
n ("0 .. 12") |% n "4"
-- But it throws an error:
• No instance for (Real ValueMap) arising from a use of ‘|%’
• In the expression: n ("0 .. 12") |% n "4"
In an equation for ‘it’: it = n ("0 .. 12") |% n "4"
```

I guess we should add a bug report on GitHub.

3 Likes

I opened an issue on GitHub, and I think I have some idea what the problem is.

2 Likes