7.7
6.2 Compounds
A macro that constructs a compound, and a match-expander that deconstructs a compound.
Examples:
> (require racket) > (require measures-with-dimensions/chemistry) > (define H2O (compound [H 2] [O 1]))
> (match H2O [(compound [a x] [b y]) (list a x b y)]) '(#<element:H> 2 #<element:O> 1)
syntax
(compound: id)
A macro that constructs a compound from an identifier representing its formula.
Examples:
> (require typed/racket) > (require typed/measures-with-dimensions/chemistry) > (define H2O (compound: H2O))
A type and a predicate for compounds.
procedure
(make-compound alist) → Compound
alist : (Listof (Pairof (Un Element Compound) Natural))
procedure
(compound-alist compound)
→ (Listof (Pairof (Un Element Compound) Natural)) compound : Compound
A constructor that creates a compound from an association list, and an accessor
to get a compound’s association list.