pike.git / lib / modules / Array.pmod

version» Context lines:

pike.git/lib/modules/Array.pmod:4:   constant diff_longest_sequence = __builtin.diff_longest_sequence;   constant diff_compare_table = __builtin.diff_compare_table;   constant longest_ordered_sequence = __builtin.longest_ordered_sequence;   constant interleave_array = __builtin.interleave_array;      constant sort = __builtin.sort;   constant everynth = __builtin.everynth;   constant splice = __builtin.splice;   constant transpose = __builtin.transpose;    + #if 1 + constant filter=predef::filter; + constant map=predef::map; + #else   mixed map(mixed arr, mixed fun, mixed ... args)   {    int e,s;    mixed *ret;       if(mappingp(arr))    return mkmapping(indices(arr),map(values(arr),fun,@args));       if(multisetp(arr))    return mkmultiset(map(indices(arr,fun,@args)));
pike.git/lib/modules/Array.pmod:54:    return ret;       case "multiset":    return rows(fun, arr);       default:    error("Bad argument 2 to Array.map().\n");    }   }    +    mixed filter(mixed arr, mixed fun, mixed ... args)   {    int e;    mixed *ret;       if(mappingp(arr))    {    mixed *i, *v, r;    i=indices(arr);    ret=map(v=values(arr),fun,@args);
pike.git/lib/modules/Array.pmod:82:    }    else    {    int d;    ret=map(arr,fun,@args);    for(e=0;e<sizeof(arr);e++) if(ret[e]) ret[d++]=arr[e];       return ret[..d-1];    }   } + #endif      mixed reduce(function fun, array arr, mixed|void zero)   {    if(sizeof(arr))    zero = arr[0];    for(int i=1; i<sizeof(arr); i++)    zero = fun(zero, arr[i]);    return zero;   }