The behavior of each nano-agent is programmed using a user-friendly language, called
nanoScheme, based on the Scheme programming language. It includes a reduced set of
primitives which is a subset of the R4RS specification (Clinger & Rees 1991). This subset
includes the following functions:
Basic calculus: + - * / = < > <= >=
Mathematics: cos sin acos asin log expt round
Predicates: number? integer? even? string? symbol? string=? eqv?
pair? null? procedure?
Strings and symbols: string->number number->string string->symbol
symbol->string substring string-length string-append
List processing: cons car cdr set-car! set-cdr!
Control and evaluation: quote eval apply load define lambda set! begin if
Most of the missing features of the Scheme specification could be added by programming
them directly in nanoScheme. This provides the application developer a high-level
interactive language which is embedded in each nano-agent. Here is an example of the
implementation of the R4RS function that returns the length of a list:
(define (length x)
(if (null? x) 0
(+ 1 (length (cdr x)))))