ListToMap(A, B)ΒΆ
list.spad line 374 [edit on github]
A: SetCategory
B: Type
ListToMap allows mappings to be described by a pair of lists of equal lengths. The image of an element x, which appears in position n in the first list, is then the nth element of the second list. A default value or default function can be specified to be used when x does not appear in the first list. In the absence of defaults, an error will occur in that case.
- match: (List A, List B) -> A -> B
match(la, lb)creates a map with no default source or target values defined by listslaandlbof equal length. The target of a source valuexinlais the valueywith the same index inlb. Error: iflaandlbare not of equal length. Note: when this map is applied, an error occurs when applied to a value missing fromla.
- match: (List A, List B, A -> B) -> A -> B
match(la, lb, f)creates a map defined by listslaandlbof equal length. The target of a source valuexinlais the valueywith the same index inlb. Argumentfis used as the function to call when the given function argument is not inla. The value returned isfapplied to that argument.
- match: (List A, List B, A) -> B
match(la, lb, a)creates a map defined by listslaandlbof equal length, whereais used as the default source value if the given one is not inla. The target of a source valuexinlais the valueywith the same index inlb. Error: iflaandlbare not of equal length.
- match: (List A, List B, A, A -> B) -> B
match(la, lb, a, f)creates a map defined by listslaandlbof equal length, and applies this map to a. The target of a source valuexinlais the valueywith the same index inlb. Argumentfis a default function to call if a is not inla. The value returned is then obtained by applyingfto argument a.
- match: (List A, List B, A, B) -> B
match(la, lb, a, b)creates a map defined by listslaandlbof equal length, and applies this map to a. The target of a source valuexinlais the valueywith the same index inlb. Argumentbis the default target value if a is not inla. Error: iflaandlbare not of equal length.
- match: (List A, List B, B) -> A -> B
match(la, lb, b)creates a map defined by listslaandlbof equal length, wherebis used as the default target value if the given function argument is not inla. The target of a source valuexinlais the valueywith the same index inlb. Error: iflaandlbare not of equal length.