functional

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2022 License: MIT Imports: 0 Imported by: 0

Documentation

Overview

package functional contains some simple helper routines to help avoid explicit loops, and provide concise conditionals. This package is experimental. Not in the sense that it's unstable ... just in the sense that I'm not sure how useful it will be. (I found some of these functions useful once ... experience will tell if a pattern emerges there ...)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func If

func If(cond bool, action ...func() error) error

If accepts a boolean argument and one or two function arguments. If the bool argument is true, then it evaluates the first function, if the bool argument is false AND two function arguments were supplied, then it calls the second function argument.

func Repeat

func Repeat(fct Repeatable, iterations uint) error

Repeat accepts a function argument, and a uint argument. It calls the function argument the number of times indicated by the uint argument, or until the function argument returns a non-nil error, whichever comes first.

func RepeatWhile

func RepeatWhile(fct RepeatableWhile) error

RepeatWhile accepts a function argument, which it calls until the function either returns false, or a non-nil error

func Unless

func Unless(cond bool, action func() error) error

Unless accepts a boolean argument and a functional argument, and executes the function argument only if the boolean is false.

Types

type Repeatable

type Repeatable func() error

type RepeatableWhile

type RepeatableWhile func() (bool, error)

Jump to

Keyboard shortcuts

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