Stuttering #691
ivanperez-keera
started this conversation in
Ideas
Stuttering
#691
Replies: 1 comment
-
|
One could also define: stutter :: Typed a => a -> Stream Bool -> Stream a -> Stream a
stutter initial cond stream = g
where
g = ifThenElse cond ([initial] ++ g) stream
stutterList :: Stream Bool
stutterList = [True, False, False, False, True] ++ stutterList
stream :: Stream Word8
stream = [1, 2, 3, 4] ++ stream
spec :: Spec
spec = trigger "j" true [arg (stutter 0 stutterList stream)]The behavior of this should be: hold the last sample for so long as the condition is true, and otherwise give me the current sample. It doesn't shift the stream that is stuttered indefinitely; that would require unbounded memory and is not (and should not be) allowed in Copilot. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
A common need in Copilot is the ability to stutter, or to temporarily hold a sample for more than one step.
For example, assuming that the argument stream below holds numbers, one could do:
In the general case, we could do:
Or, if we have defaults for some types, we could do:
Just something to think about. Maybe there's a cleaner way to do that, or a cleaner way to define a "default".
Having defaults would also help us to create updating and constructor functions for array and struct elements.
Beta Was this translation helpful? Give feedback.
All reactions