# List indexing operator in Tidal (select notes from polyphonic patterns)

**URL:** <https://uzu.lurk.org/t/list-indexing-operator-in-tidal-select-notes-from-polyphonic-patterns/5463>\
**Category:** TidalCycles\
**Tags:** resources\
**Created:** [30 September 2024 16:55 UTC](https://uzu.lurk.org/t/list-indexing-operator-in-tidal-select-notes-from-polyphonic-patterns/5463 "2024-09-30T16:55:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![geikha](https://uzu.lurk.org/user_avatar/uzu.lurk.org/geikha/32/2701_2.png) [@geikha](https://uzu.lurk.org/u/geikha)\
**Post date:** [30 September 2024 16:55 UTC](https://uzu.lurk.org/t/list-indexing-operator-in-tidal-select-notes-from-polyphonic-patterns/5463/1 "2024-09-30T16:55:00Z")

</div>

@hellocatfood asked for something like this on Discord so I wrote it as an operator:

```haskell
xs `getWrap` i = xs !! (i `mod` length xs)
a |!!| b = getWrap <$> (collect a) <*> b
a |!! b = getWrap <$> (collect a) Sound.Tidal.Context.<* b
a !!| b = getWrap <$> (collect a) Sound.Tidal.Context.*> b
a ||!! b = getWrap <$> (collect a) <<* b

d1 $ note ("<d4'minor7 d4'13 cf4'13 a4'minor7>" !!| "[0 1 . [2|3]*4]") # s "superpiano"

```

Posting here to see if anyone comes up with cool ways of using this!

---

<div class="post-metadata">

**Author:** ![gamar3is](https://uzu.lurk.org/user_avatar/uzu.lurk.org/gamar3is/32/3020_2.png) [@gamar3is](https://uzu.lurk.org/u/gamar3is)\
**Post date:** [2 October 2024 08:21 UTC](https://uzu.lurk.org/t/list-indexing-operator-in-tidal-select-notes-from-polyphonic-patterns/5463/2 "2024-10-02T08:21:39Z")

</div>

There is also `dagoarp` by yaxu:

```haskell
dagoarp :: (Num a, Eq a) => Pattern Int -> Pattern a -> Pattern a
dagoarp ipat pat = squeezeJoin $ (\l -> (octavise l) <$> ipat) <$> collect pat
   where octavise xs i = (xs !! (i `mod` length xs)) + (fromIntegral $ 12 * (i `div` length xs))

```

Usage:

```haskell
d1 $ dagoarp "0 [4 2] 3 <1 4>" 
   $ n "c'maj'5 c'min'5 e'maj'5" 
   # sound "superpiano"

```

[See here](https://github.com/tidalcycles/Tidal/issues/1050) for more
