>>>>> "C" == Christoph Rippel <crippel / primenet.com> writes: With this algorithm C> class Array C> def is_recursive?; true end C> def protected_hash (level) C> return length if level < 1 C> hsh = length C> each do |i| C> hsh = (hsh.wrap_by_1) | (hsh<0 ? 1 : 0); C> if i.is_recursive? C> hsh ^= i.protected_hash (level- 1) C> else C> hsh ^= i.hash C> end C> end C> return hsh C> end C> def hash C> untangled_hash 5 C> end and this example pigeon% cat b.rb #!/usr/bin/ruby require 'tangle' ########################## # Examples ########################## p ([1,3,3,[3,4],"a"] <=>[1,3,3,[3,4],"a"]) p ([1,3,3,[3,4],"a"] <=> [1,3,3,[3,4],"b"]) a =[1,2,3]; a << a; b =[1,2]; b << b; a << a; b << a; p a - b; p a; p b a =["a"]; b=["a"]; c = ["a"]; a << b; b << c; c << a aa = ["a"]; bb =["a"]; cc = ["a"]; aa << bb; bb << cc; cc << aa # aa << a ; aa << a; aa << a; ccl = cc.clone p a == ccl ########################## def f(x); [x,x,x,x,x,x,x]; end def g(x); f f f f f f f f x; end def h(x); g g g g g g g g x; end def i(x); h h h h h h h h x; end def j(x); i i i i i i i i x;end p (j(1) == j(1)) x = g(1) ; x << x; y = h x; p "hash" p j(35).hash p y.hash p ccl.hash x =[] ; x << x p x.hash pigeon% (it use hash-array) pigeon% time b.rb 0 -1 [3] [1, 2, 3, [...], [...]] [1, 2, [...], [1, 2, 3, [...], [...]]] true true "hash" -641768401 -641768401 194 3 real 0m0.169s user 0m0.120s sys 0m0.050s pigeon% right ? Guy Decoux