- (define-rule [CLASS] (RULE-NAME [ARGS] ...) BODY ...)syntax
Defines a rule similar to defining a function, but with an optional CLASS. If CLASS is omitted, the rule will be used if no more specific rules are defined – i.e. as a fallback rule. Multiple rules with the same RULE-NAME may be defined, provided they have different classes (otherwise the previous rule with the same name will be over-written).
Rules should return a list of rules in (RULE [ARGS] ...) form. Any non-list value, when returned, will make evaluation of the rule treated as a no-op. In other words, when the rule is evaluated and a list is returned, the rule being evaluated in the current L-systems (by step-l-system) will be replaced by the given list of rules. If no list is provided, the rule being evaluated will remain the same.
The special form branch may be included in the list of rules returned by a rule. branch should contain one or more rules. When branch is used, the state of the rules contained in the branch is split off from that of the parent of the branch.
For example, a list returned by a rule may look like:
'((leaf 1) (branch (leaf 1) (stem 1) (apex)) (stem 1) (apex))
which describes a leaf, a branch (containing a leaf, stem, and apex), a stem, and an apex.
When context-dependant or probabilistic rules are desired, see the macros context and probability in the section Macros.