#!/usr/bin/ruby

#
## Hash cyclic reference
#

var h = Hash(foo => 0, bar => [0,1])
h{:baz} = h
say h;

#
## Tree cyclic reference
#

var t = h.as_tree('root')
say t

#
## Array cyclic reference
#

var a = [1,2,3,4]
a[2] = a
say a

#
## Triple cyclic references
#

var a2 = [1,[2,3],4]

a2[3] = a2
a2[4] = a
a2[1][2] = a2[1]

say a2

#
## Mutual cyclic references
#

a[4] = h
h{:quix} = a

say h

#
## Pair cyclic reference
#

var p = Pair(1, 2)
p.second = p
say p
