View on GitHub

Magma Utils

Adds some basic functionality missing from

Aggregates

AssociativeArrayToMap (xs :: Assoc, codomain)

-> Map

The map from Keys(xs) to codomain implied by xs.

AssociativeArrayToMap (xs :: Assoc)

-> Map

The map from Keys(xs) to Universe(Values(xs)) implies by xs.

GroupBy (xs :: [], key :: UserProgram)

GroupBy (xs :: [], key)

GroupBy (xs :: {}, key :: UserProgram)

GroupBy (xs :: {}, key)

-> Assoc

The associative array whose keys are the unique values of key(x) over x in xs, and whose values are the subset of corresponding x.

ItemsList (xs :: Assoc)

-> List

Key-value pairs.

Items (xs :: [])

Items (xs :: Assoc)

-> []

Key-value pairs.

ItemsToAssociativeArray (items)

-> Assoc

The associative array such that items[i][2] is the value at key items[i][1].

KeyFunction (U :: {[[]]}, i :: RngIntElt)

KeyFunction (U :: {[Tup]}, i :: RngIntElt)

KeyFunction (U :: {[List]}, i :: RngIntElt)

KeyFunction (U :: {[Rec]}, i :: MonStgElt)

KeyFunction (U :: {[Assoc]}, i)

-> UserProgram

The function retrieving the ith entry of an element of U.

KeyFunction (U :: {[]}, i :: Map)

-> UserProgram

The map as a function.

KeyFunction (U :: {[]}, i :: Intrinsic)

-> UserProgram

The intrinsic as a function.

Keys (xs :: [])

-> {}

The indices of defined entries of xs.

RandomSubset (X :: Str, n :: RngIntElt)

RandomSubset (X :: [], n :: RngIntElt)

-> {}

A random set of n distinct elements of X.

Shuffle (X :: [], n :: RngIntElt)

-> []

A copy of the first n elements of X in a random order.

Shuffle (X :: [])

-> []

Shuffle (X :: List)

-> List

Shuffle (X :: {@@})

Shuffle (X :: {})

-> {@@}

A copy of X in a random order.

SortBy (~xs :: [], key :: UserProgram, ~permut)

SortBy (~xs :: [], key)

Sorts the sequence xs in place according to the given key.

SortBy (xs :: [], key)

-> [], GrpPermElt

Sorts the sequence according to the given key. Also returns the corresponding permutation.

SortBy (~xs :: [], key, ~permut)

Sorts the sequence xs in place by the key‘th entry.

ToIndexedSet (xs)

ToIndexedSet (xs :: {@@})

ToIndexedSet (xs :: {})

-> {@@}

Converts xs to an indexed set.

ToList (xs)

ToList (xs :: List)

ToList (xs :: Tup)

ToList (xs :: [])

-> List

Converts xs to a list.

ToMultiset (xs)

ToMultiset (xs :: {**})

ToMultiset (xs :: {})

ToMultiset (xs :: [])

-> {**}

Converts xs to a multiset.

ToSequence (xs)

ToSequence (xs :: [])

ToSequence (xs :: {})

ToSequence (xs :: {**})

ToSequence (xs :: {@@})

-> []

Converts xs to a sequence.

ToSet (xs)

ToSet (xs :: {})

ToSet (xs :: [])

ToSet (xs :: {**})

ToSet (xs :: {@@})

-> {}

Converts xs to a set.

ToTuple (xs)

ToTuple (xs :: Tup)

-> Tup

Converts xs to a tuple.

Unzip (pairs :: [Tup])

-> [], []

The first and second of each pair in pairs.

Unzip3 (triples :: [Tup])

-> [], [], []

The first, second and third of each triple in triples.

ValuesList (xs :: Assoc)

-> List

The defined values of xs.

Values (xs :: [])

Values (xs :: Assoc)

-> []

The defined values of xs.

Zip (xs :: [], ys :: [])

-> []

The corresponding pairs from each list, where both are defined.

Zip (xs :: [], ys :: [], zs :: [])

-> []

The corresponding triples from each list, where all are defined.