p_reduce and p_map implementations