Array in array, like include?

Joe Cheng wrote:

Ben wrote:

>Is there a function to checking to see if the elements of one array
>exist in another?
>
>a = [1,2,3,4,5]
>b = [1,4]
>
>a.include?(b) will only work if b is a string. I'd like to get a
>true/false if b exists in a.
>
>
How about:
(a & b).length == b.length

That should be

==code==
(a & B).length != 0
==endcode==

Because & gives an array of the common members. So if they have no
common members, it will return a zero-length array, and a
nonzero-length array otherwise.

Charles Steinman wrote:

Joe Cheng wrote:
> Ben wrote:
>
> >Is there a function to checking to see if the elements of one array
> >exist in another?
> >
> >a = [1,2,3,4,5]
> >b = [1,4]
> >
> >a.include?(b) will only work if b is a string. I'd like to get a
> >true/false if b exists in a.
> >
> >
> How about:
> (a & b).length == b.length

That should be

==code==
(a & B).length != 0
==endcode==

Because & gives an array of the common members. So if they have no
common members, it will return a zero-length array, and a
nonzero-length array otherwise.

Immediately realized that I completely misread the requirements. Sorry
for the incorrect correction. D'oh.