Re: Counting the items in anested list
Re: Counting the items in anested list
- Subject: Re: Counting the items in anested list
- From: Paul Berkowitz <email@hidden>
- Date: Thu, 17 May 2001 11:58:46 -0700
On 5/17/01 9:12 AM, "garbanzito" <email@hidden> wrote:
>
at 5/16/01, 3:49 PM -0600, they whom i call Ehsan Saffari wrote:
>
>
>
> looks like a repeat loop is the only answer.
>
>
not necessarily:
>
>
-- counts non-list items in nested lists
Steve, Ehsan wasn't trying to count non-list items. He was trying to count
the "basic" lists {"a, "b"}, {"c", "d"}, {"e", "f"} (namely 3) etc. whether
they occur as ordinary items or as sub-items of compound sublists such
{{"c", "d"}, {"e", "f"}} or as sub-sub-sub items, etc. within a master-list
such as
{{"a", "b"}, {{"c", "d"}, {"e", "f"}}}
That's what he told us at the beginning. Running your script gets the number
of strings (6), not the number of lists of the form {m, n}, namely 3.
He's trying to get every item or sub-item which is itself a list but which
doesn't itself have any further lists as subitems. I managed that with a
repeat loop incorporating a recursive handler. (Check my last post.) See if
you can do away with the repeat loop if you can.
--
Paul Berkowitz