Re: Dimension of sequences
- Posted by Fernando Bauer <fmbauer at h?t?ail.com> Sep 20, 2007
- 639 views
Hello Igor! Igor Kachan wrote: > > Fernando Bauer wrote: > > > > Igor Kachan wrote: > > > > > > > 'non-rectangular sequence' (NRS) = all sequences that aren't RS. > > > > 'dimension of RS' = maximum depth of the sequence. > > > > 'dimension of NRS' = that is the question! > > > > > > Let's see the refman.doc file now. > > > > > > Robert Craig writes: > > > > > > "Sequences can be nested to any depth, i.e. you can have sequences within > > > sequences within sequences and so on to any depth (until you run out of > > > memory)." > > > > > > I see Rob cares just about *maximum* depth here, so his definition > > > of depht, documented in refman.doc, is strongly equivalent to your > > > definition of 'dimension of RS'. > > > Same thing, you just introduce some new term, synonym. > > > > > > No? > > > > Ok. We can use "depth" as synonym of "dimension" as you prefer. Then my > > question > > is: > > What is the depth of a NRS? How can I obtain it? For now, I only know the > > depth > > of a RS. > > Hello, Fernando! > > OK, let's use just that MaxDepth() function by Ricardo, > it seems to work properly not only on 'simple' sequences, > but on any ones, it is recursive, and gives us that > pure maximum maximorum depth of any sequence. Ok. This is a possibility, and was the first reply posted by CChris to define the dimension of NRS. But, for now, I'm not sure. > > 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. > > > > 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. > > > > > > So what? What will we do with all these new terms, with > > > > > all these new notions, with all these new concepts? > > > > > > > > First of all, they facilitate our communication, since we don't have to > > > > say > > > > that whole definition phrase. > > > > Second, the terms RS and NRS can represent types in Euphoria, like > > > > vector or > > > > matrix, and so can be checked. > > > > Some algorithms can function with one and not with other type, etc.. > > > > > > Ok, but for now I do not see some real place for the 'dimension' word > > > here. Length & Depth. These old good words are very clear in > > > the specific EU context. > > > > Ok. But the Depth concept is not so clear as it seems, since nobody defined > > what it is for NRS yet. > > 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). > > Regards, > Igor Kachan > kinz at peterlink.ru Regards, Fernando