I am looking for a package for dealing with "mappings" $f\colon A\to B$ where $A$ and $B$ are finite subsets of the set of all possible (inert) expressions.
I need operations like:
- Computing $f(a)$ efficiently.
- Converting $f$ from and to a list of rules.
- Checking whether $f$ is injective (thus bijective).
- Computing the inverse function if possible.
- Listing the elements of $A$ and the set $f(A)$
- Ensuring or enforcing that the elements of $A$ and/or $B$ match a certain pattern, e.g.
_Integer. - Converting to and from a
Listfor the case that $A$ isRange[1, n]. - Efficient handling of the case that $B$ is a list of
MachineReals (PackedArray...).
I want this for the following purposes (not exhaustive):
- Abstract away different ways of representing variable-value assignments
- Abstract away differences between lists, matrices, tensors, SparseArrays, PackedArrays which can be understood as a mapping position $\to$ number.
Is there something out there that does this or could be extended easily or would you sit down the few hours it takes and program this from scratch? Am I missing some available functionality that provides a nice representation and implementation of such mappings?
Comments
Post a Comment