Very Advanced Structures
Using the struct-update package.
This page describes advanced features. You should already be familiar
with writing code in #lang racket
and using #:transparent
when
defining a struct.
Figure out how to install a package in Racket by looking in the menu under File -> Install Package…
Install the struct-update package.
Read about how to use define-struct-updaters in the help desk.
Example:
#lang racket
(require struct-update)
(define-struct game (id pts loc) #:transparent)
(define-struct-updaters game)
(require picturing-programs)
(define ex1 (make-game 10 21 "upper left"))
ex1
(game-loc-set ex1 "lower left") ;; (make-game 10 21 "lower left")
(game-pts-update ex1 add1) ;; (make-game 10 22 "upper left")