Re: Rogue list?
Re: Rogue list?
- Subject: Re: Rogue list?
- From: Michelle Steiner <email@hidden>
- Date: Thu, 10 May 2001 18:24:17 -0700
On 5/10/01 3:57 PM, Arthur J Knapp <email@hidden> wrote:
>
It was just pointed out to me that:
>
>
set emptyRecord to {} as record
>
>
actually does return an empty record, which one could then use for
>
comparison operations. It didn't even occur to me to try this, as
>
coercing a non-empty list causes an error.
Well then, how about this gem?
set foo to {} as record
set bar to {} as list
foo = bar
--> true
Oh, here are some utilities I worked up. I'm probably duplicating
someone's earlier efforts, but so what? <g>
The first returns the intersection of two lists (only those items that
appear in both lists)
set a to {1, 2, 3, 4}
set b to {3, 4, 5, 6}
set d to intersect(a, b)
--> {3, 4}
to intersect(a, b)
set c to {}
repeat with loop in a
if loop is in b then
set end of c to contents of loop
end if
end repeat
return c
end intersect
The second returns the union of two lists (all items that appear in
either list, with no duplicates)
set a to {1, 2, 3, 4}
set b to {3, 4, 5, 6}
set d to union(a, b)
--> {1, 2, 3, 4, 5, 6}
to union(a, b)
set c to a
repeat with loop in b
if loop is not in a then
set end of c to contents of loop
end if
end repeat
return c
end union
--Michelle
----------------------------------------------------------------------
| Michelle Steiner | We're not human beings having a spiritual |
| | experience. We're spiritual beings |
| email@hidden | having a human experience. |
----------------------------------------------------------------------