|
View:
New views
3 Messages
—
Rating Filter:
Alert me
|
|
|
Pdict inside PdictI have the following Pdict of Pdicts: ( a = Pdict( (
groupA: Pdict( (groupA1: Pseq([1,2,3]), groupA2: Pseq([4,5,6]) ), Pseq([\groupA1,\groupA2])
),
groupB: Pdict( (groupB1: Pseq([7,8,9]), groupB2: Pseq([10,11,12]) ), Pseq([\groupB1,\groupB2]) )
), Pseq([\groupA,\groupB],inf) );
a.asStream.nextN(20)
) I want to get 1 value from each of the Pseq, then, when all 4 have been evaluated, get the second value of each, etc. But instead I get all of the first, then all of the second, etc. Any ways around it? thanks Uri |
|
|
Re: Pdict inside Pdict>I want to get 1 value from each of the Pseq, then, when all 4 have been evaluated, get the second value of each, etc. But instead I get all of the first, then all of the second, etc. Any ways around it?
Then Pdict is not the right one. Pdict chooses the pattern from the dictionary and embeds the entire pattern before choosing again. Most patterns that take other patterns as input do this. I think Pdict is (mostly) superfluous because Psym/Pnsym do basically the same thing. My preference is to use Psym and its cousins because... you have also Psym1 and Pnsym1, which do what you want: choose the pattern, get one item from it, then choose again. Psym / Psym1 are for event patterns, Pnsym / Pnsym1 for value patterns. These are values, hence Pnsym1 below. ( a = Pnsym1( Pseq([\groupA,\groupB],inf), ( groupA: Pnsym1( Pseq([\groupA1,\groupA2],inf), ( groupA1: Pseq([1,2,3]), groupA2: Pseq([4,5,6]) ) ), groupB: Pnsym1( Pseq([\groupB1,\groupB2],inf), ( groupB1: Pseq([7,8,9]), groupB2: Pseq([10,11,12]) ) ) ) ); ) This will stop after yielding 12 values because the innermost Pseq's have repeats = 1. To get it to stream out indefinitely, make sure all Pseq's have repeats = inf. hjh -- James Harkins /// dewdrop world jamshark70@... http://www.dewdrop-world.net "Come said the Muse, Sing me a song no poet has yet chanted, Sing me the universal." -- Whitman _______________________________________________ sc-users mailing list info (subscription, etc.): http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml archive: http://www.listarc.bham.ac.uk/marchives/sc-users/ search: http://www.listarc.bham.ac.uk/lists/sc-users/search/ |
|
|
Re: Pdict inside PdictBeautiful, thanks.
|
| Free embeddable forum powered by Nabble | Forum Help |