merger

package
v0.0.0-...-9d38f52 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2017 License: Apache-2.0 Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ManyMerger

type ManyMerger func(as, bs []interface{}) ([]interface{}, error)

ManyMerger is like merge but for values from two slices which need to be merged.

func Cons

func Cons() ManyMerger

Cons merges by appending values togeter. For example, the merger of []string{"a", "b"} and []string{"c", "d"} is the slice []string{"a", "b", "c", "d"}

func Fold

func Fold(f Merger) ManyMerger

Fold merges by using function f to merge values down to a single value. The retruned slice will either be nil or have a length of one. First value pairs from as are folded into a single value, call it a. Then value pairs from bs are folded into a single value, call it b. Then a and b are merged into a single result.

Example:

    as = [ 1 2 3 ]
    bs = [ 7 8 9 ]

     f = +

     a = f(f(1, 2), 3)
       = f(3, 3)
       = 6

     b = f(f(7, 8), 9)
       = f(15, 9)
       = 24

result = f(a, b)
       = 30

type Merger

type Merger func(a, b interface{}) (interface{}, error)

Merger for merging a and b into something new.

Jump to

Keyboard shortcuts

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