• 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:Meeting a matrix of conditions
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re:Meeting a matrix of conditions


  • Subject: Re:Meeting a matrix of conditions
  • From: nino petriliggieri <email@hidden>
  • Date: Tue, 14 Sep 2004 12:01:44 +0200

what about:

script a
    property p : {{"av", "bx", "bw", "bz", "dx", "ev"}, "apple", ¬
        {"aw", "cv", "dy", "dz", "ez"}, "orange", ¬
        {"ax", "cw", "cx", "ey"}, "banana", ¬
        {"ay", "cz", "dv", "ew"}, "mango", ¬
        {"az", "bv", "by", "cy", "dw", "ex"}, "tomato"}
    on c(x)
        repeat with i from 1 to count of p by 2
            if x is in item i of p then return item (i + 1) of p
        end repeat
    end c
end script

set x to some item of {"a", "b", "c", "d", "e"}
set y to some item of {"v", "w", "x", "y", "z"}
set z to a's c(x & y)

nino

> I figure there must be a more clever & efficient way to do this:
>
> set x to some item of {"a", "b", "c", "d", "e"}
> set y to some item of {"v", "w", "x", "y", "z"}
>
> if (x & y) is in {"av", "bx", "bw", "bz", "dx", "ev"} then
> set z to "apple"
> else if (x & y) is in {"aw", "cv", "dy", "dz", "ez"} then
> set z to "orange"
> else if (x & y) is in {"ax", "cw", "cx", "ey"} then
> set z to "banana"
> else if (x & y) is in {"ay", "cz", "dv", "ew"} then
> set z to "mango"
> else if (x & y) is in {"az", "bv", "by", "cy", "dw", "ex"} then
> set z to "tomato"
> end if
>
> I figured coercing into one string was better than if x = "a" and y =
> "v" then...

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Prev by Date: Re: Your message to Applescript-users awaits moderator approval RE: IS: Swapping SE Format Styles for List Postings -- WAS: Re: String > to list conversion
  • Next by Date: Re: unicode text coercion to number bug?
  • Previous by thread: Re: Meeting a matrix of conditions
  • Next by thread: unicode text coercion to number bug?
  • Index(es):
    • Date
    • Thread