packages feed

hsc3-lang-0.7: Help/Pattern/pswitch1.help.lhs

pswitch1 :: [P a] -> P Int -> P a
pswitch1m :: IntMap (P a) -> P Int -> P a

  list - patterns to index
 which - index

The pattern of indices is used select which pattern
to retrieve the next value from.  Only one value 
is selected from each the pattern.

This is in comparison to pswitch, which embeds the 
pattern in its entirety.  pswitch1 switches every value.

pswitch1 is implemented in terms of pswitch1m.

> import Control.Applicative
> import Sound.SC3.Lang.Pattern

> let { p = pseq [1, 2, 3] pinf
>     ; q = pseq [65, 76] pinf
>     ; r = pswitch1 [p, q, pure 800] (pseq [2, 2, 0, 1] pinf) }
> in take 24 (evalP 0 r)