Re: Sifting a list sans loop
Re: Sifting a list sans loop
- Subject: Re: Sifting a list sans loop
- From: Kai Edwards <email@hidden>
- Date: Sun, 27 Jan 2002 09:23:47 +0100
>
Date: Sat, 26 Jan 2002 22:55:03 -0600
>
From: ehsan saffari <email@hidden>
>
Subject: Re: Sifting a list sans loop
>
To: AS Users <email@hidden>
>
>
A Stoned wizard wrote to me off-list:
>
>
> ----------------------------------------------------------------------
>
> set l to {"one", "two", "three", "four", {1, 2, 3}}
>
>
>
> set t to l's text
>
> set lst to l's lists
>
> ----------------------------------------------------------------------
>
>
Paradise!
>
>
and similarly one can get a list's dates andd numbers too.
So there I was, playing about with the problem. I tried Akua's 'edit list',
as Paul had suggested - and found that his memory had indeed served him
well. (It doesn't seem to work.)
I also re-checked the ASLG - since I'd vaguely recalled something about the
'whose' filter working with application objects only. The relevant piece (on
page 173) confirmed that 'whose' can't be used to filter AppleScript objects
- such as lists, records or strings.
So - back to the drawing board. After playing around with the syntax for a
while, I was getting ready to give up when - eureka! I'd stumbled upon a
secret, 'magic' formula:
set oldList to {"cat", "dog", {"car", "bus", "tractor"}, "horse", "cow",
{"van"}}
set {newStrings, newLists} to {oldList's strings, oldList's lists}
--> {{"cat", "dog", "horse", "cow"}, {{"car", "bus", "tractor"}, {"van"}}}
Just as I was about to post this wonderful new discovery, I received your
latest message, along with a sprinkling of similar responses - all
suggesting how simple the answer really was.
Yeah - thanks, guys! ;)
(Naturally, I'm still delighted that you got your solution - and I learned
quite a lot from the exercise, too!)
Kai
--
**********************************
Kai Edwards Creative Resources
1 Compton Avenue Brighton UK
Telephone +44 (0)1273 326810
**********************************