SuperCollider CLASSES

Pair

LISP-like two element cells
Inherits from: Collection : Object

Description

NOTE: Implementation incomplete. See J concepts in SC for similar functionality.

Most methods are inherited from the superclasses.

Class Methods

*new (linkDown, linkAcross)

Return new instance.

*newFrom (collection)

Convert collection (e.g. arrays of arrays) to pairs.

Inherited class methods

Instance Methods

-size

Return the size when linking across.

-depth

Return the size when linking down.

-do (function)

Iterate over the two elements.

Traverse Same like: -depthFirstPreOrderTraversal

-depthFirstPreOrderTraversal (function)

Traverse the data structure first link down, then across (see Examples).

-depthFirstPostOrderTraversal (function)

Traverse the data structure from bottom up (see Examples).

Inherited instance methods

Undocumented instance methods

-linkAcross

-linkAcross = value

-linkDown

-linkDown = value

-traverse (function)

Examples

a = Pair(Pair(Pair(1, 2), 4), Pair(5, 6));

a.size;
a.depth;
a.do { |x| x.postln };
a.traverse { |x| x.postln };
a.depthFirstPreOrderTraversal { |x| x.postln };
a.depthFirstPostOrderTraversal { |x| x.postln };


// alternative instantiations:

Pair.newFrom([1, [2, [[4, 5], 6]]]);

[1, [2, [[4, 5], 6]]].as(Pair); // equivalent.