I must code a radix sort for a decimal keytype.
Very well. So the keytype works only if all keys have the same length since it sorts keys digits by digits repetitively from power of the base of least to most significance.
Is it possibile to give a range to a signed integer formal type ? only range <>
is accepted, I wonder why. It could be useful to specify a range of value a type
is refused. It would be nice to specify that a type should include a given range. But predicates aren’t allowed either in formal type declarations.
For now I’m content to ask the user a function to produces the given digit for a given position.
generic
type DigitType is (<>);
type Element is private;
KeyLength : Positive;
with function GetDigit (E: Element; Power: Natural) return DigitType;
type Indextype is (<>);
type ListType IS array (Indextype range <>) OF Element;
procedure decimal_radix_sort (List: IN OUT ListType);
It seems the most generalist formula, even though no important mathematical property of the function can be specified/proved etc. Tell me if you have other ideas.