Skip to content

Fully replacing the structure/values of a pattern #155

Answered by yaxu
larkob asked this question in Q&A
Discussion options

You must be logged in to vote

In Haskell there is const which just returns it's first argument (in js that would be (a,b) => a), allowing e.g. every 3 (const "d e f) "a ~".

Similarly we could add a function to Pattern in strudel that just returns its argument Pattern.prototype.replace = a => a, then do "~ a2" .replace("g2 f2") .note() .piano() .out()

I think that would work for your example case but I have a feeling it's not really what you're getting at, when you mention the problem of losing context. For example:

n("a ~").gain(1.1).every(3, setOut(n("b b")))

That would lose the final b.. Because there are no events in the second half of the cycle to replace with the events in the 'b' pattern.

Yep @felixroos this is …

Replies: 3 comments 4 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
4 replies
@larkob
Comment options

@felixroos
Comment options

@yaxu
Comment options

@larkob
Comment options

Answer selected by larkob
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants