Re: Sequence depths please explain

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

You can use this function, which is part of my General Functions package:

global function MaxDepth(object o)
--Returns the maximum depth of object o.
--Atoms have depth 0.
    integer n, x
    if atom(o) then
        return 0
    else
        n = 1
        for i = 1 to length(o) do
            x = 1 + MaxDepth(o[i])
            if x > n then
              n = x
            end if
        end for
        return n
    end if
end function

A string returns 1. An atom returns 0. A composite sequence returns 2 or
more.

----- Original Message -----
From: "Tony Steward" <tony at locksdownunder.com>
To: "EUforum" <EUforum at topica.com>
Sent: Monday, February 25, 2002 6:56 AM
Subject: Sequence depths please explain


>
> Hi all,
> How can I tell if a sequence is a single sequence of if it contains more
> sequences.
>
> eg
> test = {Tony Steward} -- Single sequence
> test = {{Tony Steward}{lockmaster67 at aol.com}{22432345}} -- Multi
>
> Thanks Tony
>
>
>
>

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

Search



Quick Links

User menu

Not signed in.

Misc Menu