kmap

package module
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: May 31, 2022 License: EPL-2.0 Imports: 8 Imported by: 0

README

kmap CI/CD Go Reference

A program for generating k-maps based on user input.

EXAMPLES
> kmap
  
  What is the size of the k-map? (3): 
  3
  What are the arguments to the k-map?: 
  0,1,6,7
  What are the don`t care conditions of of the k-map?:
  2, 4
  
                y
    -----------------
    | 1 | 1 | 0 | X |
    -----------------
  x | X | 0 | 1 | 1 |
    -----------------
            z
> kmap -s 2 -a '1, 2' -dc ''
          y
    ---------
    | 0 | 1 |
    ---------
  x | 1 | 0 |
    ---------
INSTALLATION
  • With Go 1.17+ installed:

    > go install github.com/noah-friedman/kmap/bin/kmap@latest
    
  • Without Go 1.17+ installed:

    See Releases for pre-compiled binaries.

USAGE

After running the kmap program the user is prompted for three inputs:

  • The size of the k-map (a.k.a. the number of variables in the k-map)

    Valid: [2-4]

  • The arguments of the k-map

    Valid: [0-2size)

  • The don't care conditions of the k-map

    Valid: [0-2size)

NOTE: The arguments and don't care conditions must not overlap.

When inputting the arguments of the k-map the user may provide a series of valid numbers seperated by any characters as long as each separation contains the same characters. Otherwise, an error will occur.

Instead of inputting parameters directly, the user may provide arguments to the kmap program:

  • -s or -size for the size parameter
  • -a or -args for the arguments to the k-map
  • -dc or -dont-care for the don't care conditions of the k-map
EXIT CODES
  • 0: Everything went fine, the program executed successfully
  • 1: Some kind of bug or error in the way I wrote the program.
  • 2: Some kind of bug in a library called by the program (possibly due to a misunderstanding of the library on my part).

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Parse

func Parse(input, delim string) ([]int, error)

Parse takes an input string and converts it to arguments that can then be used to create a Kmap.

func Program

func Program(in, out *os.File) (int, error)

Program is run by the main function in the executable package. It returns an exit code.

Types

type Kmap

type Kmap struct {
	Values           [][]*bool
	Size, Rows, Cols int
}

Kmap represents a Karnaugh map, or k-map (https://en.wikipedia.org/wiki/Karnaugh_map). It provides values contained in the k-map it represents as well as properties containing data about the k-map (these properties should NOT be modified). A Kmap should be created using the NewKmap() function.

func NewKmap

func NewKmap(size int, args, dontCare []int) (*Kmap, error)

NewKmap is the constructor for the Kmap type.

func (*Kmap) Format

func (kmap *Kmap) Format() string

Format creates a formatted string that can be outputted containing the data of the Kmap.

Directories

Path Synopsis
bin

Jump to

Keyboard shortcuts

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