Specifications

28 Using Pure Data
Message sequences
Several messages can be stored in the same message- box as a sequence if sepa-
rated by commas, so
2, 3, 4, 5
is a message-box that will send four values one
after another when clicked or banged. T his happens instantly (in logical time).
This is often confusing to beginners when comparing sequences to lists. When
you send the contents of a message box containing a sequence all the elements
are sent in one go, but a s separate messages in a s tream. Lists on the other
hand, which are not separated by commas, also send all the elements at the
same time, but as a single list mess age. Lists and sequences can be mixed, so a
message box might contain a sequence of lists.
SECTION 3.4
List objects and operations
Lists can be quite an advanced topic and we could devote an entire chapter
to this subject. Pd has all the capabilities of a full programming language like
LISP, using only list operations, but like that language all the more complex
functions are defined in terms of just a few intrinsic opera tions and abstrac-
tions. The list-abs collection by Frank Barknecht and others is available in
pd-extended. It contains scores of advanced operations like sorting, reversing,
inserting, searching and pe rforming conditional operations on every element of
a list. Here we will look at a handful of very simple objects and leave it as
an exercise to the reader to research the mo re advanced capabilities of lists for
building sequencers and data analysis tools.
Packing and unpacking lists
The usual way to create and disassemble lists is to use
pack
and
unpack
. Arguments
are given to each w hich are type identifiers, so
pack f f f f
is an object that will
wrap up four floats given on its inlets into a single list. They should be presented
in right to left order so that the hot inlet is filled last. You can also give float
values directly as arguments of a
pack
object where you want them to be fixed,
so
pack 1 f f 4
is legal, the first and last list elements will be 1 and 4 unless
over-ridden by the inlets, and the two middle o nes will be variable.
pack s s f f
foo
bar
2
1
s packed
fig 3.16: List packing
Start by changing the right number in Fig . 3.1 6,
then the one to its left, then click on the sym-
bol boxes and type a short string before hitting
RETURN. When you enter the last symbol connected
to the hot inlet of
pack
you will see the data re-
ceived by Fig. 3.17 appear in the display boxes
after it is unpacked.