home/ atoms/ strudel-fmap-withvalue

withValue (alias fmap) applies a function to every Hap's value without changing timing

withValue (aliased fmap) is the Functor map operation on patterns: it returns a new pattern identical in structure to the original but with each Hap’s value transformed by the given function. Timing is untouched — only the value payload changes — so it cannot corrupt the temporal structure, making it the safe way to post-process values. It corresponds directly to Haskell’s fmap for functors and is the conceptual foundation for any value-only transformation in Strudel (transposition, scaling, mapping to control parameters).

Examples

“0 1 2”.withValue(v => v + 10).log() // yields 10, 11, 12 at the same timing as 0, 1, 2

Assessment

Write a one-liner that transposes every note up 7 semitones using withValue, and name the alias under which this same operation is also exposed.

“Returns a new pattern, with the function applied to the value of each hap. It has the alias `fmap`.”
corpus · strudel-internals-pattern-as-function-of-time-functor-applic · chunk 1