Project

General

Profile

Feature #6515 ยป feature_6515_array_part_of_v2.patch

lellisga (Li Ellis Galardo), 05/30/2012 11:32 PM

View differences:

array.c
4690 4690
 *     ary.part_of? other_ary   ->   bool
4691 4691
 *
4692 4692
 *  Array 'A' is part of another array 'B' if
4693
 *  each element from 'A' are include in 'B'
4693
 *  each element from 'A' are included in 'B'
4694 4694
 *
4695 4695
 *  [ "a", "c" ].part_of? [ "a", "b", "c" ]    #=> true
4696 4696
 *  [ "a", "d" ].part_of? [ "a", "b", "c" ]    #=> false
......
4702 4702
rb_ary_part_of(VALUE ary1, VALUE ary2)
4703 4703
{
4704 4704

  
4705
    if (ary1 == ary2) return Qtrue;
4706
    VALUE ary3, ary4;
4707
    ary3 = rb_ary_and(ary1, ary2);
4708
    ary4 = rb_ary_diff(ary1, ary3);
4709
    return rb_ary_empty_p(ary4);
4705
    ary2 = rb_ary_and(ary1, ary2);
4706
    ary2 = rb_ary_diff(ary1, ary2);
4707
    return rb_ary_empty_p(ary2);
4710 4708
}
4711 4709

  
4712 4710
/*