builtin

package
v0.0.0-...-83ff670 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2023 License: BSD-3-Clause Imports: 1 Imported by: 0

Documentation

Overview

Package builtin provides the Hermes builtin functions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Errorf

func Errorf(where any, msg string, args ...any) any

Errorf reports an error at the given position.

func FoldLeft

func FoldLeft[In, Out any](s []In, init Out, fn func(In, Out) Out) Out

FoldRight returns fn(s[len-1], fn(s[len-2], ... fn(s[0], init))).

func FoldRight

func FoldRight[In, Out any](s []In, init Out, fn func(In, Out) Out) Out

FoldRight returns fn(s[0], fn(s[1], ... fn(s[len-1], init))).

func Fresh

func Fresh[ID any]() ID

Fresh returns a new, unique identifier.

func Map

func Map[In, Out any]([]In, func(In) Out) []Out

Map returns []Out{fn(s[0]), fn(s[1]), ..., fn(s[len-1])}.

func MapIndex

func MapIndex[In, Out any]([]In, func(int, In) Out) []Out

MapIndex returns []Out{fn(0, s[0]), fn(1, s[1]), ..., fn(len-1, s[len-1])}.

func Sorted

func Sorted[Elem cmp.Ordered](Set[Elem]) []Elem

func Sum

func Sum[In, Out any]([]In, func(In) Out) Out

TODO(mdempsky): Out must be a semigroup.

func Zip

func Zip[In1, In2, Out any](s1 []In1, s2 []In2, fn func(In1, In2) Out) ([]Out, bool)

Zip returns {Just(fn(s1[0], s2[0])), Just(fn(s1[1], s2[1])), ..., Just(fn(s1[len-1], s2[len-1]))}, true, if len(s1) == len(s2). Otherwise, it returns nil, false.

Types

type List

type List[Elem any] opaque

func Cons

func Cons[Elem any](head Elem, tail List[Elem]) List[Elem]

func ListOf

func ListOf[Elem any](elems ...Elem) List[Elem]

func (List[Elem]) Slice

func (List[Elem]) Slice() []Elem

type Maybe

type Maybe[Elem any] opaque

func Fmap

func Fmap[In, Out any](Maybe[In], func(In) Out) Maybe[Out]

func Just

func Just[Elem any](Elem) Maybe[Elem]

func (Maybe[Elem]) Get

func (Maybe[Elem]) Get() (Elem, bool)

type Set

type Set[Elem comparable] opaque

func NewSet

func NewSet[Elem comparable](...Elem) Set[Elem]

func (Set[Elem]) Difference

func (Set[Elem]) Difference(...Set[Elem]) Set[Elem]

func (Set[Elem]) Empty

func (Set[Elem]) Empty() bool

func (Set[Elem]) Has

func (Set[Elem]) Has(Elem) bool

func (Set[Elem]) Intersect

func (Set[Elem]) Intersect(...Set[Elem]) Set[Elem]

func (Set[Elem]) Len

func (Set[Elem]) Len() int

func (Set[Elem]) Union

func (Set[Elem]) Union(...Set[Elem]) Set[Elem]

Jump to

Keyboard shortcuts

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