Pattern to array

Hello, I wanted to convert a pattern to a list, is there any method that does this?
I know there is .list on a pattern, but this works on nothing nested, I think what I want becomes clear in the following example:

Pseq([1,2,1,2,3,4],1).list
//output what i want: [ 1, 2, 1, 2, 3, 4 ]
Pseq([Pseq([1,2],2),3,4]).list
//output not what i want: [ a Pseq, 3, 4 ]
//i want: [ 1, 2, 1, 2, 3, 4 ]
Place([1,2,3,[4,5]]).list
//output not want i want: [ 1, 2, 3, [ 4, 5 ] ]
//i want: [ 1, 2, 3, 4, 1, 2, 3, 5, ]

Is it possible to get an array from an pattern so that the array does not repeat itself?
And for pattern that have a randomness maybe it is required to have a maximum amount of elements in the list.
Or should I just embed this in a stream and append every element into a list in a routine? this seems kinda inconventional.
Thank you very much!

You can use .asStream. For example:

a = Place([1, 2, 3, [4, 5]], inf).asStream;
a.nextN(8);

// -> [ 1, 2, 3, 4, 1, 2, 3, 5 ]
2 Likes

if you are certain that the pattern is finite in length, you can also use .all

(
a = Place([1, 2, 3, [4, 5]], 2).asStream;
b = a.all; // b == [ 1, 2, 3, 4, 1, 2, 3, 5 ]
)
2 Likes

Thank you very much, thats it!