Skip to main content
Glama
emicklei

melrōse musical expression player

by emicklei
replace.go1.26 kB
package op import ( "bytes" "fmt" "github.com/emicklei/melrose/core" ) // Replace will replace a Sequenceable upon creating a Sequence. type Replace struct { Target core.Sequenceable From, To core.Sequenceable } // S is part of Sequenceable func (r Replace) S() core.Sequence { if rep, ok := r.Target.(core.Replaceable); ok { return rep.Replaced(r.From, r.To).S() } return r.Target.S() } // Storex is part of Storable func (r Replace) Storex() string { var b bytes.Buffer fmt.Fprintf(&b, "replace(") if st, ok := r.Target.(core.Storable); ok { fmt.Fprintf(&b, "%s,", st.Storex()) } else { fmt.Fprintf(&b, "%v,", r.Target) } if st, ok := r.From.(core.Storable); ok { fmt.Fprintf(&b, "%s,", st.Storex()) } else { fmt.Fprintf(&b, "%v,", r.From) } if st, ok := r.To.(core.Storable); ok { fmt.Fprintf(&b, "%s)", st.Storex()) } else { fmt.Fprintf(&b, "%v)", r.To) } return b.String() } // Return a new Replace in which any occurrences of "from" are replaced by "to". func (r Replace) Replaced(from, to core.Sequenceable) core.Sequenceable { if core.IsIdenticalTo(r, from) { return to } if rep, ok := r.Target.(core.Replaceable); ok { return Replace{Target: rep.Replaced(from, to), From: r.From, To: r.To} } return r }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/emicklei/melrose'

If you have feedback or need assistance with the MCP directory API, please join our Discord server