# Pattern to list?

Simple-sounding question here. I'm trying to use patterns to make "spicy" lists.

The following example is maybe a bit weird, but you don't have to worry about the details. Let's say I create a pattern:

`toScale [0, 2, 5] (fromIntegral <\$> round <\$> segment 12 (range 1 14 \$ abs (sine * (fast 2 \$ sine)))) ` .

This pattern maps time to values:

``````(0>1/12)|26
(1/12>⅙)|48
(⅙>¼)|41
(¼>⅓)|14
(⅓>5/12)|2
(5/12>½)|12
(½>7/12)|17
(7/12>⅔)|12
(⅔>¾)|2
(¾>⅚)|2
(⅚>11/12)|2
(11/12>1)|5
``````

How does one create a list out of the values?

I'm expecting a list with 12 elements, `[26, 48, 41, 14, 2, 12, 17, 12, 2, 2, 2, 5]`.

I've tried putting square braces around the pattern, but that creates a list of patterns--not what i'm after. I tried appending ` :: [Double]` and some other things and searches but no luck.

1 Like

Hey !
the following seems to work:

``````patternToList :: Pattern a -> [a]
patternToList pat = (map value (queryArc pat (Arc 0 1)))
``````

I'd be interested what you're gonna do with the lists

1 Like

Yeah that works great! Thank you so much!

I'm trying to use the lists in `nTake` and see what you can get with the new state memory in Tidal.

1 Like

I would warn that there's a gotcha here - `queryArc` doesn't sort its output, so there's no guarantee that list you get will be time-ordered. If you want to make sure you have a "chronological" output you'd want to do something like

``````import Data.List
patternToList pat = map value \$ sortOn whole \$ queryArc pat (Arc 0 1)
``````
1 Like

Thank you kindly, @bgold . I do indeed want this chronological input.