Pair: table of contents
Classes | Collections > Ordered

Pair : Collection : Object

LISP-like two element cells


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

Most methods are inherited from the superclasses.

Class Methods, linkAcross)

Return new instance.


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

Inherited class methods

Instance Methods


Return the size when linking across.


Return the size when linking down.


Iterate over the two elements.

Traverse Same like: -depthFirstPreOrderTraversal


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


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

Inherited instance methods

Undocumented instance methods


.linkAcross = value


.linkDown = value



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

a.depth; { |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.