Documentation
¶
Index ¶
- func CondenseSpaces(s string) string
- func GCD(a, b int) int
- func IntList(s string) ([]int, error)
- func LCM(nums ...int) int
- func MustAtoi(s string) int
- func ParseInputLines[T any](filename string, skipBlank bool, parseLine LineParser[T]) ([]T, error)
- func ParseInputLinesSections[T any](filename, firstSection string, t T, skipBlank bool, ...) (T, error)
- func ReadInputLines(filename string) ([]string, error)
- func StringLineParser(line string) (string, error)
- type LineParser
- type SectionLineParser
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CondenseSpaces ¶
CondenseSpaces replaces multiple spaces with a single space and trims whitespace from the start and end of the given string. For example, ' a b c ' becomes 'a b c'.
func ParseInputLines ¶
func ParseInputLines[T any](filename string, skipBlank bool, parseLine LineParser[T]) ([]T, error)
ParseInputLines applies the parseLine function to each line in the input file.
func ParseInputLinesSections ¶
func ParseInputLinesSections[T any]( filename, firstSection string, t T, skipBlank bool, sectionParsers map[string]SectionLineParser[T], ) (T, error)
ParseInputLinesSections parses an input file that can contain multiple sections. sectionParsers is a map of section name to a SectionLineParser, which parses a line and returns the name of the section to move to. Ignores blank lines.
func ReadInputLines ¶
ReadInputLines returns the raw lines in the input file.
func StringLineParser ¶
StringLineParser returns the given line as-is.
Types ¶
type LineParser ¶
LineParser parses a generic type from the given line.
Click to show internal directories.
Click to hide internal directories.