make-enumeration(3scm) Scheme Programmer's Manual make-enumeration(3scm)

make-enumeration - create a new enumeration type

(import (rnrs))                     ;R6RS
(import (rnrs enums))               ;R6RS

(make-enumeration symbol-list)

Creates a new enumeration type whose universe consists of the symbols in symbol-list and returns that universe as an enumeration set whose universe is itself and whose enumeration type is the newly created enumeration type.

The canonical order of the symbols is according to their first appearance in the list.

Returns a single value; an enumeration set.

(enum-set->list (make-enumeration '(g a t t a c a)))
    => (g a t c)

Enumeration types are used for expressing sets of flags, as in, e.g., file-options(3scm). The syntax define-enumeration(3scm) is more commonly used.

Enumerations are unique to R6RS. The (r6rs enums) package at https://snow-fort.org/ provides a compatible library.

This procedure can raise exceptions with the following condition types:
&assertion (R6RS)
The wrong number of arguments was passed or an argument was outside its domain. In particular, symbol-list must be a list of symbols.

define-enumeration(3scm)

R6RS

Enumerations first appeared in R6RS.

This page is part of the scheme-manpages project. It includes materials from the RnRS documents. More information can be found at https://weinholt.se/scheme/manpages/.

2023-08-27