Re: Dimension of sequences

new topic     » goto parent     » topic index » view thread      » older message » newer message

Fernando Bauer wrote:

> 
> Hello Igor!
> 
> [snipped]
> > [snipped]

Hello Fernando!

> > OK, interesting, the specific structure of a sequence is involved.
> > Let's wait.
> > 
> 
> Here is my current implementation of "dimension of sequences" involving its
> structure:
> }}}
<eucode>
> function Dimension(object o)
> integer ini
> object base
> sequence s
> 
>    if atom(o) then return 0 end if
>    if length(o)=0 then return 1 end if
>    if length(o)=1 then return 1+Dimension(o[1]) end if   
>    s = {}
>    ini = 1
>    o = o = o
>    base = o[1]
>    for i = 2 to length(o) do
>       if not equal(base, o[i]) then
>          if i > ini+1 then 
>             s = append(s,1+Dimension(base))
>          else
>             s = append(s,Dimension(base))
>          end if
>          base = o[i]
>          ini = i
>       end if
>    end for
>    if ini = 1          then return 1+Dimension(o[1]) end if
>    if ini = length(o)  then return append(s,Dimension(o[ini])) end if
>    return append(s,1+Dimension(o[ini]))
> end function
> 
> procedure ShowDimension(object o)
> puts(1,"Dimension of ")
> print(1, o)
> puts(1," = ")
> print(1,Dimension(o))
> puts(1,"\n")
> end procedure
> 
> object obj
> -- Create an object formed by rectangular sequences with incremental dimension
> obj = {1}
> for i = 2 to 4 do
>    obj = append(obj, repeat(obj[i-1],1))
> end for
> 
> for i=1 to length(obj) do
>    ShowDimension(obj[i])
> end for
> 
> ShowDimension(1)
> ShowDimension({})
> ShowDimension({2})
> ShowDimension({3,4})
> ShowDimension({5,{6}})
> ShowDimension({7,{8},9})
> ShowDimension({10,{11},{12}})
> ShowDimension({13,{14,15}})
> ShowDimension({{16,17},{18,19}})
> ShowDimension({{20,21},{22}})
> ShowDimension({23,{24,{{25,26},{27,28}}}})
> ShowDimension({1,{1},{1,1},{1,1,1},{1,1},{1},1})
> ShowDimension({1,{1},{1},{1,1},{1,1},{{1,1},{1,1},{1,1}}})
> ShowDimension({obj[1],obj[2],obj[3],obj[4]})
> ShowDimension({obj[4],obj[3],obj[2],obj[1]})
> ShowDimension({obj[1],{obj[2],{obj[3],{obj[4]}}},obj[1]})
> 
> for i = 1 to length(obj) do
>    for j = 1 to length(obj) do
>       for k = 1 to length(obj) do
>          ShowDimension({obj[i], obj[j], obj[k]})
>       end for
>    end for
> end for
> </eucode>
{{{

> 
> Thanks to everyone who has contributed to this topic!

I'm sorry I was off line all those days, and will try your
new current implementation for "dimension" next week, if I
have some spare time for it.

But your initial question about dimension seems to be answered
already, you do have your own vision and solution of the problem
about "NRS dimension" now, so let's finish this thread, OK?

Regards,
Igor Kachan
kinz at peterlink.ru

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu