callbacks

package
v0.6.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 1, 2026 License: BSD-3-Clause Imports: 3 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package callbacks has Go functions that take Python callables, and call them before returning.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Apply

func Apply(x float64, f func(x float64) float64) float64

Apply returns f(x).

func CallKept

func CallKept(i int)

CallKept calls the func Keep stored, outside the call it was passed to.

func CallKeptCheck

func CallKeptCheck(i int) bool

CallKeptCheck reports what the func KeepCheck stored answers for i, outside the call it was passed to.

func Count

func Count(n int, keep func(i int) bool) int

Count returns how many of 0..n-1 keep says yes to.

func Describe

func Describe(fun func(v interface{}))

Describe calls fun with a string and a fmt.Stringer, as interface{} values. They arrive as strings, made by fmt.Sprintf("%s", v).

func Each

func Each(n int, fun func(i int, label string))

Each calls fun for i in 0..n-1, with a label made from i.

func InGoroutine

func InGoroutine(fun func(i int))

InGoroutine calls fun from another goroutine, and waits for it.

func Keep

func Keep(fun func(i int))

Keep stores fun, for CallKept to call after Keep has returned.

func KeepCheck

func KeepCheck(check func(i int) bool)

KeepCheck stores check, for CallKeptCheck to call after KeepCheck has returned.

func Label added in v0.6.1

func Label(i int, f func(i int) string) string

Label returns f(i). The plain-C backends skip it: they can't take a string back from Python.

func Mixed

func Mixed(fun func(on bool, x float64, u uint8))

Mixed calls fun with a bool, a float and an unsigned integer.

func Sum

func Sum(n int, val func(i int) int) int

Sum adds up what val returns for 0..n-1.

func Twice

func Twice(fun func())

Twice calls fun, which takes no arguments, two times.

func Widest

func Widest(n int, size func(i int) uint) uint

Widest returns the largest of what size returns for 0..n-1.

Types

type Counter

type Counter struct {
	N int
}

Counter counts how many times it has been visited.

func (*Counter) Check

func (c *Counter) Check(fun func(c *Counter, n int) bool) bool

Check calls fun with the counter itself, and reports what it answered.

func (*Counter) Visit

func (c *Counter) Visit(times int, fun func(c *Counter, n int))

Visit calls fun with the counter itself, which arrives as a handle.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL