• 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: "Mark J. Reed" <email@hidden>
  • Date: Mon, 26 Jan 2009 07:46:47 -0500

Why do all these solutions use globals?  Is it a performance thing?
(Kneejerk: globals bad!)



On 1/26/09, Philip Aker <email@hidden> wrote:
> On 2009-01-26, at 04:30:15, Michael Schmidt (BRT) wrote:
>
>> If you have a list of strings only, you can also use this:
>
>> on flattenList(theList)
>> 	set retour to {}
>> 	if theList ≠ {} then
>> 		set AppleScript's text item delimiters to "\", \""
>> 		set retour to run script "{\"" & theList & "\"}"
>> 		set AppleScript's text item delimiters to ""
>> 	end if
>> 	return retour
>> end flattenList
>
> Try this:
>
> global gFlatList
> on FlattenList(theList)
> 	global gFlatList
> 	repeat with i in theList
> 		if (class of i is list) then
> 			my FlattenList(i)
> 		else
> 			set end of gFlatList to contents of i
> 		end if
> 	end repeat
> end FlattenList
>
> set deep to {{"item 1", 0, {"item 3", "item 4", "item 5"}},
> {{name:"Michael"}, "item 7", "item 8"}, 999}
> set gFlatList to {}
> my FlattenList(deep)
> gFlatList
>
>
> Philip Aker
> echo email@hidden@nl | tr a-z@. p-za-o.@
>
> Democracy: Two wolves and a sheep voting on lunch.
>
>

--
Sent from Gmail for mobile | mobile.google.com

Mark J. Reed <email@hidden>
 _______________________________________________
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: Philip Aker <email@hidden>
References: 
 >Re: Flattening Nested Lists (From: Barry Wainwright <email@hidden>)
 >Re: Flattening Nested Lists (From: Brian Christmas <email@hidden>)
 >Re: Flattening Nested Lists (From: "Michael Schmidt (BRT)" <email@hidden>)
 >Re: Flattening Nested Lists (From: Philip Aker <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