Enumerations: Difference between revisions

(revert de-indenting of CL and Scheme under Lisp, and removal of Scheme value-definitions (because values are called for in the task description); kept predicate example)
Line 3:
Create an enumeration of types with and without values.
=={{header|Ada}}==
Ada enumeration types have three distinct attributes, the enumeration literal, the enumeration position, and the representation value. The position value (starting with 0) is implied from the order of specification of the enumeration literals in the type declaration.; Theit position values provideprovides the ordering for the enumeration values. In the example below, apple (position 0) is less than banana (position 1) which is less than cherry (position 3) due to their positions, not due to their enumeration literal. ThereAn isenumeration norepresentation, necessarywhen relationshipgiven, betweenmust thenot enumeration position andviolate the enumeration representationorder.
 
type Fruit is (apple, banana, cherry); -- No specification of the representation value;
for Fruit use (apple => 1, banana => 2, cherry => 34); -- specification of the representation values
 
Ada enumeration types are non-numeric discrete types. They can be used to index arrays, but there are no arithmetic operators for enumeration types; instead, there are predecessor and successor operations. Characters are implemented as an enumeration type in Ada.
 
=={{header|BASIC}}==
Anonymous user