pike.git / lib / modules / Array.pmod

version» Context lines:

pike.git/lib/modules/Array.pmod:144:    return e;    return -1;    }       error("Bad argument 2 to search_array().\n");   }      //! Applies the function @[sum] columnwise on the elements in the   //! provided arrays. E.g. @expr{sum_array(`+,a,b,c)@} does the same   //! as @expr{`+(a[*],b[*],c[*])@}. - array sum_arrays(function(mixed ...:mixed) sum, array ... args) + array sum_arrays(function(int(0..0) ...:mixed) sum, array ... args)   { -  +  // FIXME: int(0..0) in the function prototype above is a kludge. +  // See the FIXME in sort_array.    array ret = allocate(sizeof(args[0]));    for(int e=0; e<sizeof(args[0]); e++)    ret[e] = sum( @column(args, e) );    return ret;   }      //! @decl array sort_array(array arr, function|void cmp, mixed ... args)   //!   //! This function sorts the array @[arr] after a compare-function   //! @[cmp] which takes two arguments and should return @expr{1@} if the
pike.git/lib/modules/Array.pmod:168:   //!   //! The remaining arguments @[args] will be sent as 3rd, 4th etc. argument   //! to @[cmp].   //!   //! If @[cmp] is omitted, @[`>()] is used instead.   //!   //! @seealso   //! @[map()], @[sort()], @[`>()], @[dwim_sort_func], @[lyskom_sort_func],   //! @[oid_sort_func]   //! - array sort_array(array arr, function(mixed,mixed,mixed ...:int)|void cmp, + array sort_array(array arr, function(int(0..0),int(0..0),mixed ...:int)|void cmp,    mixed ... args)   { -  +  // FIXME: The two int(0..0) in the function prototype above are +  // kludges to avoid strict_type warnings on correctly typed cmp +  // functions. The correct way to fix it would be to infer the real +  // type from the array elements in arr. +     array bar,tmp;    int len,start;    int length;    int foop, fooend, barp, barend;       arr+=({});       if(!cmp || cmp==`>)    {    sort(arr);
pike.git/lib/modules/Array.pmod:723:   }      //! Returns 1 if all of the elements in @[a] fulfills the requirement   //! @[predicate]( @[a][@i{i@}], @@@[extra_args] ), otherwise 0. The   //! predicate should return non-zero for an element that meets the   //! requirements and zero for those that do not.   //! @example   //! Array.all( ({ 2, 4, 6, 8 }), `<, 17 )   //! @seealso   //! @[any], @[has_value] - int(0..1) all( array a, function(mixed, mixed ...:mixed) predicate, + int(0..1) all( array a, function(int(0..0), mixed ...:mixed) predicate,    mixed ... extra_args )   { -  +  // FIXME: int(0..0) in the function prototype above is a kludge. +  // See the FIXME in sort_array.    foreach( a, mixed elem ) -  if( !predicate( elem, @extra_args ) ) +  if( !predicate( [int(0..0)] elem, @extra_args ) )    return 0;    return 1;   }      //! Returns 1 if any of the elements in @[a] fulfills the requirement   //! @[predicate]( @[a][@i{i@}], @@@[extra_args] ), otherwise 0. The   //! predicate should return non-zero for an element that meets the   //! requirements and zero for those that do not.   //! @example   //! Array.any( ({ 2, 4, 6, 8 }), `>, 5 )   //! @seealso   //! @[all], @[has_value] - int(0..1) any( array a, function(mixed, mixed ...:mixed) predicate, + int(0..1) any( array a, function(int(0..0), mixed ...:mixed) predicate,    mixed ... extra_args )   { -  +  // FIXME: int(0..0) in the function prototype above is a kludge. +  // See the FIXME in sort_array.    foreach( a, mixed elem ) -  if( predicate( elem, @extra_args ) ) +  if( predicate( [int(0..0)] elem, @extra_args ) )    return 1;    return 0;   }      //! Splits an array in two, according to an arbitration function   //! @[arbiter]. The elements in @[a] who return non-zero for the   //! expression @[arbiter]( @[a][@i{i@}], @@@[extra_args] ) end up in   //! the first sub-array, the others in the second. The order is   //! preserved from the original array.   //! @example   //! Array.partition( enumerate( 9 ), lambda(int n) { return n>3 && n<7; } );   //! > ({ ({ 4, 5, 6 }), ({ 0, 1, 2, 3, 7, 8 }) })   //! @seealso   //! @[filter], @[`/], @[`%] - array(array) partition( array a, function(mixed, mixed ...:mixed) arbiter, + array(array) partition( array a, function(int(0..0), mixed ...:mixed) arbiter,    mixed ... extra_args )   { -  +  // FIXME: int(0..0) in the function prototype above is a kludge. +  // See the FIXME in sort_array.    array first = ({}), second = ({});    foreach( a, mixed elem ) -  if( arbiter( elem, @extra_args ) ) +  if( arbiter( [int(0..0)] elem, @extra_args ) )    first += ({ elem });    else    second += ({ elem });    return ({ first, second });   }      //! Threats an Array as a stack and pushes the element onto the   //! end.   //! @example   //! Array.push(({ "a", "b", "c", "d" }), "e");