8.16.0.1
kw-make-struct
(require kw-make-struct) | package: kw-make-struct-lib |
source code: https://github.com/AlexKnauth/kw-make-struct
syntax
(make/kw struct-id field ...)
(make/kw struct-id field-pat ...)
field = expr | field-keyword expr field-pat = pat | field-keyword pat
Like make from unstable/struct,
except allowing keywords.
make/kw is also defined as a match expander.
Examples:
> (require kw-make-struct racket/match) > (struct foo (a b c) #:transparent) > (make/kw foo 'a 'b 'c) (foo 'a 'b 'c)
> (make/kw foo #:a 'a #:b 'b #:c 'c) (foo 'a 'b 'c)
> (make/kw foo #:a 'a 'b 'c) (foo 'a 'b 'c)
> (make/kw foo #:c 'c 'a #:b 'b) (foo 'a 'b 'c)
> (match (foo 'a 'b 'c) [(make/kw foo #:a a #:b b #:c c) (list a b c)]) '(a b c)
Creates an instance of struct-id, where [field-id expr]
means that the field-id field will be the value of expr.
make/fld is also defined as a match expander.
Examples: