Re: Dimension of sequences
- Posted by Igor Kachan <kinz at peter?ink?ru> Sep 24, 2007
- 660 views
Hello Fernando! Fernando Bauer wrote: > > Hello Igor! > > Igor Kachan wrote: > > [snip] > > > > See please: > > }}} <eucode> > > global function MaxDepth(object o) > > integer n, x > > if atom(o) then > > return 0 > > else > > n = 0 > > for i = 1 to length(o) do > > x = MaxDepth(o[i]) > > if x > n then > > n = x > > end if > > end for > > return n + 1 > > end if > > end function -- it is function by Ricardo Forno, genfunc.e lib > > > > ? MaxDepth({{{{}}},{},{{},{{{{{{{{{{{{}}}}}}}}}}}}},{{{{{{{{}}}}}}}}}) > > ? MaxDepth({{{{1}}},{1},{{1},{{{{{{{{{{{{1}}}}}}}}}}}}},{{{{{{{{1}}}}}}}}}) > > </eucode> {{{ > > The maximum depth is 14, all right. > > Count please the '{' signs, opening the deepest sequence, > > to be sure. > > It seems to be a good parameter for description of a sequence. > > Now a sequence has its own second dimension, and may be > > considered as some 2-dimensional object, which can contain > > description of any-dimentional real and unreal objects - > > vectors, matrixes, tensors, lists, arrays, trees, books, > > images ... etc, etc. > > Sequence itself really has two own dimensions - length and depth, > > I think now. So attempts to give it some *single* dimension > > may be not very productive. > > Just to make clear, this concept of 2-dimensional object, or dimensionality > 2 as you define, is a higher abstract concept, and is not my original > definition > of "dimension" which is your Depth. I do not think that it is more abstract, it is very clear, if you'll just draw a sequence as the pretti_print() draws or as it is drawn below? for example:
? MaxDepth({{{{1}}},{1},{{1},{{{{{{{{{{{1,{1},1}}}}}}}}}}}},1,{{{{{{{{1}}}}}}}}}) -- --{ } -- { },{1},{ },1,{ } -- { } {1},{ } { } -- {1} { } { } -- { } { } -- { } { } -- { } { } -- { } { } -- { } {1} -- { } -- { } -- { } -- {1, ,1} -- {1} or: -- --{ } -- { },{1},{ },1,{ } -- { } {1},{ } { } -- {1} { } { } -- { } { } -- { } { } -- { } { } -- { } { } -- { } {1} -- { } -- { } -- { } -- {1, ,1} -- {1}
It is something like to just icicles or stalactites. Did you see the icicles in Brasilia? And these dimensions are very demonstative, not abstract at all. They are just dimensions of some sheet of paper, needed to draw this graphical representation of some sequence. But you'll need not only the *maximum* depth, but also the *maximum* length. The maximum length can be on any depth, not only on depth 1. The function for calculating of maximum length may be very simple. [snip] > > > > Then, I do not think now that the 'rectangular' word is very > > > > good for your purpose, maybe, 'regular', as some short > > > > for 'regularly nested', is better. > > > > > > > Ok. But I think "rectangular" is sligthly more precise than "regular", > > > since > > > I could think that the following sequence is regular: > > > repeat({1,{1,1}},n) where n is any integer number. And that sequence is > > > NRS. > > > Well, this is only a definition problem. > > > > Ricardo names these sequences as 'simple sequences'. > > No. Ricardo defines "simple sequences" as "sequences formed only by atoms" > (depth=1). > The sequence repeat({1,{1,1}},n) has sub-sequences therefore it's not a simple > sequence. > A simple sequence is always a RS, but not always a RS is a simple sequence. Ok, no matter, the Ricardo's function works properly with any sequence, so if it is "simple" or it is "complicated" really is not a question. > > OK, now we can calculate that Depth (good, let's name the maximum depth > > as Depth) with Ricardo's function. > But then think about this (bad) analogy: > If someone ask you about the depth of the Pacific Ocean, then you would say > the maximum depth of it, since you have defined this way. However we know that > its depth depends on the place. > (notice that this depth is not our discussed concept of Depth). Good analogy, not bad, I always can say that the depth of the Pacific Ocean is *down to about* 11000 meters. But if I'll know the Depth of the Pacific Ocean, I do know the dimensions of a sheet of paper to draw the depth profiles of that ocean. Regards, Igor Kachan kinz at peterlink.ru