defaultops.go 590 B

1234567891011121314151617181920212223242526272829
  1. package defaultops
  2. import (
  3. "flow/registry"
  4. "math"
  5. "math/rand"
  6. )
  7. // New create a registry
  8. func New() *registry.R {
  9. r := registry.New()
  10. // String functions
  11. // Math functions
  12. r.Add(
  13. math.Abs, math.Cos, math.Sin, math.Exp, math.Exp2, math.Tanh, math.Max, math.Min,
  14. ).Tags("math").Extra("style", registry.M{"color": "#386"})
  15. registry.Describer(
  16. r.Add(rand.Int, rand.Intn, rand.Float64),
  17. r.Add("Perm", func(n int) []int {
  18. if n > 10 { // Limiter for safety
  19. n = 10
  20. }
  21. return rand.Perm(n)
  22. }),
  23. ).Tags("rand").Extra("style", registry.M{"color": "#486"})
  24. return r
  25. }