On this page:
compound
compound:
Compound
compound?
make-compound
compound-alist
6.3.90.900

6.2 Compounds

syntax

(compound [sub n] ...)

 
  sub : (Un Element Compound)
  n : Natural
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))

type

Compound

procedure

(compound? v)  Boolean

  v : Any
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.