24.2. Data Types

There a number of basic data types in this Scheme, new ones may also be added but only through C++ functions. This basic types are

Symbols:

symbols atoms starting with an alphabetic character. Unlike numbers and strings, they may be used as variables. Examples are

a bcd f6 myfunc 
plus cond

Symbols may be created from strings by using the function intern

Numbers:

In this version of scheme all numbers are doubles, there is no distinction between floats, doubles and ints. Examples are

1
1.4
3.14
345
3456756.4345476

Numbers evaluate to themselves, that is the value of the atom 2 is the number 2.

Strings:

Strings are bounded by the double quote characters ". For example

"a"
"abc"
"This is a string"

Strings evaluate to themselves. They may be converted to symbols with the function intern. If they are strings of characaters that represent numbers you can convert a string to a number with the function parse-number. For example

(intern "abc") => abc
(parse-number "3.14") => 3.14

Although you can make symbols from numbers you should not do that.

Double quotes may be specified within a string by escaping it with a backslash. Backslashes therefore also require an escape backslash. That is, "ab\"c" contains four characters, a, b, " and c. "ab\\c" also contains four characters, a, b, \ and c. And "ab\\\"c" contains five characters a, b, \, " and c.

Lists or Cons

Lists start with a left parenthesis and end with a right parenthesis with zero or more s-expression between them. For example

(a b c)
()
(b (b d) e)
((the boy) saw (the girl (in (the park))))

Lists can be made by various functions most notably cons and list. cons returns a list whose first item is the first item in the list, standardly called its car, and whose remainder, standardly called its cdr, is the second argument of cons.

(cons 'a '(b c)) => (a b c)
(cons '(a b) '(c d)) => ((a b) c d)

Functions:

Functions may be applied explicity bu the function apply or more normally as when the appear as the first item in a list to be evaluated. The normal way to define function is using the define function. For example

(define (ftoc temp)
   (/ (* (- temp 32) 5) 9))

This binds the function to the variable ftoc. Functions can also be defined anonymously which sometimes is convinient.

(lambda (temp)
   (/ (* (- temp 32) 5) 9))

returns a function.

Others:

other internal types are support by Festival's scheme including some inportant object types use for synthesis such as utterances, waveforms, items etc. The are normally printed as in the form

#<Utterance 6234>
#%lt;Wave 1294>

The rpint form is a convinience form only. Enter that string of characters will not allow a reference to that object. The number is unique to that object instance (it is actually the internal address of the object), and can be used visually to note if objects are the same or not.