Re: Counting the items in anested list
Re: Counting the items in anested list
- Subject: Re: Counting the items in anested list
- From: garbanzito <email@hidden>
- Date: Thu, 17 May 2001 10:12:24 -0600
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
on count_items(a_list)
local the_count
set the_count to 0
if class of a_list is not list then
set the_count to 1
else
if a_list is not {} then
set the_count to count_items(first item of a_list)
try -- fails if only 1 element
set the_count to the_count + (count_items(items 2 through -1 of a_list))
end try
end if -- not empty
end if -- is a list
return the_count
end count_items
steve harley email@hidden