Greetings,
What kinds of ways are there to construct or apply number patterns from functions?
I was trying to import some custom arpeggiation code into Tidal. A minor victory was getting an old function to compile/work in Haskell:
wrap :: Int -> [Int] -> Int -> Int
wrap x seq jump
| s < 0 = seq!!(s+len) + (j-1)*jump
| otherwise = seq!!s + j*jump
where len = length seq
j = x `div` len
s = x `mod` len
By reading Pattern.hs
, I found that withValue
could be used to apply a number function with a single argument to a number pattern.
withValue (\a -> wrap a [0,2,4] 7) "0 [2 4] [3 3 3]"
giving the expected result:
t> (0>⅓)|0
(⅓>½)|4
(½>⅔)|9
(⅔>⁷₉)|7
(⁷₉>⁸₉)|7
(⁸₉>1)|7
Now, withValue
just works for a function with a single argument and a single pattern input.
What if I had multiple inputs to the function that I wanted to feed with number patterns? (My goal function has the type signature: Int -> Int -> [Int] -> Float -> Int -> Int
... thus I would like to map at least two input Int patterns and possibly an array pattern.) What kind of strategies are there for constructing number patterns from complicated functions?
best regards