make-enumeration(3scm)

πŸ“¦ version 0-unstable-2024-02, in nixpkgs unstable

πŸ’… make-enumeration β€” create a new enumeration type

okay bestie, welcome to make-enumeration(3scm) from the Scheme Programmer's Manual, we're gonna get you sorted ✨


πŸŽ€ NAME

make-enumeration β€” create a new enumeration type. that's it. that's the whole job. iconic honestly.


πŸ“š LIBRARY

so like, this is an R6RS girlie, and you can pull it in two ways:

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

either one, slay πŸ’–


✨ SYNOPSIS

(make-enumeration symbol-list)

one argument, one job, no drama.


πŸ¦‹ DESCRIPTION

okay so here's the tea: make-enumeration creates a brand new enumeration type whose universe is made up of the symbols in symbol-list. and then β€” plot twist β€” it hands you back that universe as an enumeration set whose universe is itself, and whose enumeration type is the shiny new enumeration type it just made. main character energy fr fr πŸ‘‘

the canonical order of the symbols? that's just the order they show up in first in the list. first appearance wins, periodt. no alphabetical nonsense, no sorting, we respect the debut order πŸŽ€


🌸 RETURN VALUES

returns a single value: an enumeration set. one value. that's it. lowkey refreshing πŸ’œ


πŸ“ EXAMPLES

watch the duplicate t's and a's get filtered like they're not invited:

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

see? g, a, t, c β€” first appearances only, in order. ate and left no crumbs πŸ”₯


🌈 APPLICATION USAGE

enumeration types are for expressing sets of flags β€” y'know, like in, e.g., file-options(7scm). ngl though, the syntax define-enumeration(7scm) is the one people actually reach for more commonly. so like, know this one exists, but don't be surprised if the other one's the one on everyone's feed πŸ™ˆ


πŸ’€ COMPATIBILITY

enumerations are unique to R6RS β€” nobody else has them, so don't go looking. the (r6rs enums) package over at https://snow-fort.org/ provides a compatible library if you need one 🫢


😭 ERRORS

this procedure can raise exceptions with these condition types:

  • &assertion (R6RS) β€” the wrong number of arguments got passed, or an argument was outside its domain. in particular, symbol-list has to be a list of symbols. like, actually. a list. of symbols. no cap 🚨

πŸ‘‘ SEE ALSO


⭐ STANDARDS

R6RS. that's the standard, that's the whole standard, we love a one-liner πŸ’…


🌸 HISTORY

enumerations first appeared in R6RS. that's their origin story. short, sweet, iconic ✨


πŸ’– AUTHORS

this page is part of the scheme-manpages project. it includes materials from the RnRS documents. more info lives at https://github.com/schemedoc/manpages/ 🧚


okay that's the whole page bestie, you're literally an enumeration expert now πŸŽ€ this was make-enumeration(3scm), from the Scheme Programmer's Manual, dated 2023-08-27 β€” go forth and build your universes πŸ’œβœ¨

πŸ“¦ where this page comes from