ops

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2022 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Add added in v0.3.0

func Add[T constraints.Integer | constraints.Float | ~string](a, b T) T

Add performs the `+` operation for the two inputs, returning the result.

Example
package main

import (
	"fmt"

	"github.com/BooleanCat/go-functional/iter"
	"github.com/BooleanCat/go-functional/iter/ops"
)

func main() {
	total := iter.Fold[int](iter.Lift([]int{1, 2, 3}), 0, ops.Add[int])

	fmt.Println(total)
}
Output:

6

func UnwrapOption

func UnwrapOption[T any](o option.Option[T]) T

UnwrapOption may be used as an operation for iter.Map in order to unwrap all options in an iterator.

func UnwrapResult

func UnwrapResult[T any](r result.Result[T]) T

UnwrapResult may be used as an operation for iter.Map in order to unwrap all results in an iterator.

Types

This section is empty.

Jump to

Keyboard shortcuts

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