compare

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2023 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package compare validates tuples against a schema.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Tuples

func Tuples(schema q.Tuple, candidate q.Tuple) []int

Tuples checks if the candidate Tuple conforms to the given schema. The schema Tuple may contain Variable or MaybeMore while the candidate must not contain either. The elements of each Tuple are compared for equality. If an element of the schema Tuple is a Variable, then the candidate's corresponding element must conform for the constraints of the Variable. If all the elements match then nil is returned. If an element doesn't match, then an array is returned specifying the index path to the first mismatching element. For instance, given the following candidate tuple...

Tuple{55, Tuple{"hello", "world", Tuple{67}}}

...if the element with value `67` didn't match then the returned array would be `[]int{1,2,0}`. If the tuples aren't the same length then the length of the shorter Tuple is used as the mismatching index.

Types

This section is empty.

Jump to

Keyboard shortcuts

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