Re:Meeting a matrix of conditions
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