golrn

package
v0.0.0-...-36c972f Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ModulePath = "github.com/lenkite/learn/golrn"

Functions

func ArrayBasics

func ArrayBasics()

func BlankSwitch

func BlankSwitch()

func ConcatTo

func ConcatTo[S fmt.Stringer, P Plusser](s []S, p []P) []string

ConcatTo takes a slice of elements with a String method and a slice of elements with a Plus method. The slices should have the same number of elements. This will convert each element of s to a string, pass it to the Plus method of the corresponding element of p, and return a slice of the resulting strings.

func CustomErrors

func CustomErrors()

func DemoArraysAndSlices

func DemoArraysAndSlices()

func DemoConcatTo

func DemoConcatTo()

func DemoControlStructures

func DemoControlStructures()

func DemoErrors

func DemoErrors()

func DemoGenerics

func DemoGenerics()

func DemoGoRoutines

func DemoGoRoutines()

func DemoMaps

func DemoMaps()

func DemoStringify

func DemoStringify()

func DemoStructs

func DemoStructs()

func DemoSumIntsOrFloats

func DemoSumIntsOrFloats()

func ErrorWithStackTrace

func ErrorWithStackTrace()

func ErrorWrapChain

func ErrorWrapChain()

func Errorf

func Errorf(format string, args ...interface{}) error

func JoinUnwrap

func JoinUnwrap()

func MapAsSet

func MapAsSet()

func MapBasics

func MapBasics()

func MapCommaOkIdiom

func MapCommaOkIdiom()

func SelectDemo

func SelectDemo()

func SliceAppends

func SliceAppends()

func SliceBasics

func SliceBasics()

func SliceCopying

func SliceCopying()

func SliceExpressions

func SliceExpressions()

func SliceLenCap

func SliceLenCap()

func SliceOverlapping

func SliceOverlapping()

func SliceViaMake

func SliceViaMake()

func SquareJob

func SquareJob()

func Stringify

func Stringify[T fmt.Stringer](s []T) (ret []string)

Stringify calls the String method on each element of s, and returns the results.

func StructConversions

func StructConversions()

func SumNumbers

func SumNumbers[K comparable, V Number](m map[K]V) V

SumNumbers sums the values of map m. It supports both int64 and float64 as types for map values.

func Switch

func Switch()

Types

type Animal

type Animal struct {
	Name string
	Age  uint
}

Animal has a Name and an Age to represent an animal.

func (Animal) Plus

func (a Animal) Plus(s string) string

func (Animal) String

func (a Animal) String() string

String makes Animal satisfy the Stringer interface.

type ListElement

type ListElement[T any, U any] struct {
	// contains filtered or unexported fields
}

ListElement is an element in a linked list with a head. Each element points back to the head.

type ListHead

type ListHead[T any, U any] struct {
	// contains filtered or unexported fields
}

ListHead is the head of a linked list.

type Number

type Number interface {
	int64 | float64
}

type Plusser

type Plusser interface {
	Plus(string) string
}

Plusser is a type constraint that requires a Plus method. The Plus method is expected to add the argument to an internal string and return the result.

type Status

type Status int
const (
	NotOdd Status = iota + 1
	NotEven
)

type StatusErr

type StatusErr struct {
	Status  Status
	Message string
}

func (StatusErr) Error

func (se StatusErr) Error() string

Jump to

Keyboard shortcuts

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