matrix

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2024 License: MPL-2.0 Imports: 1 Imported by: 1

README

Quickstart

Below an example main.go:

package main

import (
    "fmt"
    "github.com/maxgio92/krawler/pkg/matrix"
)

var (
	columns = []matrix.Column{
		{OrdinateIndex: 0, Points: []string{"A", "B"}},                // part
		{OrdinateIndex: 0, Points: []string{"1", "2", "3", "4", "5"}}, // part
		{OrdinateIndex: 0, Points: []string{"w", "x", "y", "z"}},      // part
		{OrdinateIndex: 0, Points: []string{"E", "F", "G", "H"}},      // part
		{OrdinateIndex: 0, Points: []string{"A", "B"}},                // part
	}
)

func main() {
	for _, v := range columns {
		fmt.Println(v.Points)
	}
	combinations, err := matrix.GetColumnOrderedCombinationRows(columns)
	if err != nil {
		panic(err)
	}
	fmt.Println(combinations)
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetColumnOrderedCombinationRows

func GetColumnOrderedCombinationRows(columns []Column) ([]string, error)

The combinations are built concatenating one element per column into a row, and traversing all the columns' elements by shifting them from the last to the first columns (decremental abscissa order).

(ordinate) y ^ | 4 | 3 Z |B 2 Y |A 1 X -----------> x (abscissa)

Provided the sample scenario above, this function should combine the elements in the order below:

A + 1 + X A + 1 + Y A + 1 + Z A + 2 + X ... B + 4 + Z

Types

type Column

type Column struct {
	CurrentOrdinateIndex int
	Points               Points
}

type ErrUnsopportedPointType

type ErrUnsopportedPointType struct {
	// contains filtered or unexported fields
}

func NewErrUnsopportedPointType

func NewErrUnsopportedPointType() *ErrUnsopportedPointType

func (*ErrUnsopportedPointType) Error

func (e *ErrUnsopportedPointType) Error() string

type Points

type Points interface{}

Jump to

Keyboard shortcuts

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