pike.git / lib / modules / Array.pmod

version» Context lines:

pike.git/lib/modules/Array.pmod:142:    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. @expr{sum_array(`+,a,b,c)@} does the same + //! provided arrays. E.g. @expr{sum_arrays(`+,a,b,c)@} does the same   //! as @expr{`+(a[*],b[*],c[*])@}.   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;   }
pike.git/lib/modules/Array.pmod:245:    tmp=arr;    arr=bar;    bar=tmp;    }       return arr;   }      //! Get multiple columns from an array.   //! - //! This function is equvivalent to + //! This function is equivalent to   //! @pre{   //! map(ind, lambda(mixed i) { return column(x, i); })   //! @}   //!   //! @seealso   //! @[column()]   array(array) columns(array x, array ind)   {    array(array) ret=allocate(sizeof(ind));    for(int e=0;e<sizeof(ind);e++) ret[e]=column(x,ind[e]);
pike.git/lib/modules/Array.pmod:571:   {    array res;    mixed last;    if (!sizeof(a)) return ({});    res=({last=a[0]});    foreach (a,mixed v)    if (v!=last) last=v,res+=({v});    return res;   }    - //! Make an array of the argument, if it isn't already. A zero_type + //! Make an array of the argument, if it isn't already. An undefined   //! argument gives the empty array. This is useful when something is   //! either an array or a basic datatype, for instance in headers from   //! the MIME module or Protocols.HTTP.Server.   //! @param x   //! Result depends of the argument type:   //! @dl   //! @item arrayp(x)   //! arrayify(x) => x - //! @item zero_type(x) + //! @item undefinedp(x)   //! arrayify(x) => ({})   //! @item otherwise   //! arrayify(x) => ({ x })   //! @enddl   array arrayify(void|array|mixed x)   { -  if(zero_type(x)) return ({}); +  if(undefinedp(x)) return ({});    if(arrayp(x)) return [array]x;    return ({ x });   }      //! Sort with care of numerical sort for OID values, e.g.   //! "1.2.1" before "1.11.1".   //! @returns   //! @int   //! @value -1   //! @expr{a<b@}
pike.git/lib/modules/Array.pmod:690:   //! If the optional @[needle] argument is omitted, @[count] instead   //! works similar to the unix command @tt{sort|uniq -c@}, returning   //! a mapping with the number of occurrences of each element in   //! @[haystack]. For array or mapping @[haystack]s, it's the values   //! that are counted, for multisets the indices, as you'd expect.   //! @seealso   //! @[String.count], @[search], @[has_value]   int|mapping(mixed:int) count(array|mapping|multiset haystack,    mixed|void needle)   { -  if(zero_type(needle)) +  if(undefinedp(needle))    {    mapping(mixed:int) res = ([]);    if(mappingp(haystack))    haystack = values([mapping]haystack);    foreach((array)haystack, mixed what)    res[what]++;    return res;    }    return sizeof(filter(haystack, `==, needle));   }