pike.git / lib / modules / Array.pmod

version» Context lines:

pike.git/lib/modules/Array.pmod:108:    for(e=0;e<sizeof(arr);e++)    if(([array(function(mixed...:mixed))]arr)[e](@args))    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. @tt{sum_array(`+,a,b,c)@} does the same - //! as @tt{`+(a[*],b[*],c[*])@}. + //! 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 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 @tt{1@} if the + //! @[cmp] which takes two arguments and should return @expr{1@} if the   //! first argument is larger then the second. Returns the sorted array   //! - @[arr] is not sorted destructively.   //!   //! 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],
pike.git/lib/modules/Array.pmod:656:    }    if(!seen)    return ({ d1, d2 }); // No change.    return ({ [array(array)]r1 + d1[seen..],    [array(array)]r2 + d2[seen..] });   }      //! Like @[Array.diff], but tries to generate bigger continuous chunks of the   //! differences, instead of maximizing the number of difference chunks. More   //! specifically, @[greedy_diff] optimizes the cases where @[Array.diff] returns - //! @code{({ ..., A, Z, B, ({}), C, ... })@} - //! @code{({ ..., A, X, B, Y+B, C, ... })@} + //! @expr{({ ..., A, Z, B, ({}), C, ... })@} + //! @expr{({ ..., A, X, B, Y+B, C, ... })@}   //! into the somewhat shorter diff arrays - //! @code{({ ..., A, Z, B+C, ... })@} - //! @code{({ ..., A, X+B+Y, B+C, ... })@} + //! @expr{({ ..., A, Z, B+C, ... })@} + //! @expr{({ ..., A, X+B+Y, B+C, ... })@}   array(array(array)) greedy_diff(array from, array to)   {    array(array) d1, d2;    [d1, d2] = diff(from, to);    [d2, d1] = low_greedy_diff(d2, d1);    return low_greedy_diff(d1, d2);   }      //! @decl int count(array|mapping|multiset haystack, mixed needle)   //! @decl mapping(mixed:int) count(array|mapping|multiset haystack)