• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Flattening Nested Lists
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Flattening Nested Lists


  • Subject: Re: Flattening Nested Lists
  • From: Rick Gordon <email@hidden>
  • Date: Mon, 26 Jan 2009 02:15:16 -0800

Thanks, Barry.

------------------

On 1/26/09 at 9:52 AM +0000, Barry Wainwright wrote in a message entitled
"Re: Flattening Nested Lists":

>On 26 Jan 2009, at 09:30, Rick Gordon wrote:
>
>>I'm spending too much time trying to do something that I think should be easy enough: flattening a list of lists (of lists (of lists)), so that the the result is a list containing no list elements. Can someone point me to some code or instruction on handling this? I'm figuring that it probably takes a recursive handler, but I'm getting recursed in my own mind, at this point.
>
>
>set aList to {{"item 1", "item 2", {"item 1", "item 2", "item 3"}}, {"item 1", "item 2", "item 3"}, "item 3"}
>set newList to {}
>my flattenList(aList)
>newList
>
>on flattenList(theList)
>	global newList
>	repeat with anItem in theList
>		if class of anItem is list then
>			my flattenList(anItem)
>		else
>			copy anItem to end of newList
>		end if
>	end repeat
>end flattenList

--

___________________________________________________

RICK GORDON
EMERALD VALLEY GRAPHICS AND CONSULTING
___________________________________________________

WWW:   http://www.shelterpub.com
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Re: Flattening Nested Lists
      • From: Brian Christmas <email@hidden>
References: 
 >Flattening Nested Lists (From: Rick Gordon <email@hidden>)
 >Re: Flattening Nested Lists (From: Barry Wainwright <email@hidden>)

  • Prev by Date: Re: Flattening Nested Lists
  • Next by Date: Re: Flattening Nested Lists
  • Previous by thread: Re: Flattening Nested Lists
  • Next by thread: Re: Flattening Nested Lists
  • Index(es):
    • Date
    • Thread