Skip to main content
Glama
emicklei

melrōse musical expression player

by emicklei
random.go838 B
package op import ( "fmt" "math/rand" "time" "github.com/emicklei/melrose/core" ) type RandomInteger struct { From core.HasValue To core.HasValue rnd *rand.Rand last int } func NewRandomInteger(from, to core.HasValue) *RandomInteger { rnd := &RandomInteger{ From: from, To: to, rnd: rand.New(rand.NewSource(time.Now().Unix())), } rnd.Next() return rnd } // Storex is part of Storable func (r RandomInteger) Storex() string { return fmt.Sprintf("random(%s,%s)", core.Storex(r.From), core.Storex(r.To)) } // Value is part of HasValue func (r *RandomInteger) Value() any { return r.last } // Next is part of Nextable func (r *RandomInteger) Next() any { f := core.Int(r.From) t := core.Int(r.To) if t < f { r.last = f return f } r.last = f + r.rnd.Intn(t-f+1) return r.last } // TODO Replaceable

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