Alias: collect

@chainable
@category  Collections
@param     array     $xs
@param     callable  $f
@return    array
557935
public static function map($xs, $f)
    {
        $ys = array();
        foreach ($xs as $k => $x) {
            $ys[$k] = call_user_func($f, $x, $k, $xs);
        }
        return $ys;
    }
132514
public static function findManyByNameOrCreate(array $tags, string $group = null, string $locale = null): Collection
    {
        // Expects array of tag names
        return collect($tags)->map(function ($tag) use ($group, $locale) {
            return static::findByNameOrCreate($tag, $group, $locale);
        });
    }
980215
function requestNextHashTree(ws) {
	db.query("SELECT COUNT(1) AS count_left FROM catchup_chain_balls", function (rows) {
		if (rows.length > 0) {
			if (catchup_balls_at_start == -1) { // first time to get all catchup ball number
				catchup_balls_at_start = rows[0].count_left;
			}
			catchup_balls_left = rows[0].count_left;
		}
	});
	db.query("SELECT ball FROM catchup_chain_balls ORDER BY member_index LIMIT 2", function (rows) {
		if (rows.length === 0)
			return comeOnline();
		if (rows.length === 1) {
			db.query("DELETE FROM catchup_chain_balls WHERE ball=?", [rows[0].ball], function () {
				comeOnline();
			});
			return;
		}

		let from_ball = rows[0].ball;
		let to_ball = rows[1].ball;

		// don't send duplicate requests
		for (let tag in ws.assocPendingRequests) {
			if (ws.assocPendingRequests[tag].request.command === 'get_hash_tree') {
				console.log("already requested hash tree from this peer");
				return;
			}
		}

		//	...
		sendRequest(ws, 'get_hash_tree', {from_ball: from_ball, to_ball: to_ball}, true, handleHashTree);
	});
}
122860
public static function get($mKeys = null, $bXssClean = false)
    {
        $aArray = isset($_GET) ? $_GET : [];
        return static::getItemsFromArray($mKeys, $bXssClean, $aArray);
    }
634487
function(xs, f) {
      for (var i = 0, len = xs.length; i < len; i++) {
        var x = xs[i];
        f(x, i, xs);
      }
    }
930293
function (oTree, sSeparator) {
			var oObject = this.toHierarchy(oTree),
				aFilters = [];

			function collect(sName, oObject) {
				var aChildren, bChildren;
				if (typeof oObject === 'object') {
					if (oObject['']) {
						aFilters.push(sName + '/');
						return;
					}
					aChildren = Object.keys(oObject);
					bChildren = aChildren.length;
				}
				if (bChildren) {
					aChildren.forEach(function (sChild) {
						if (sChild === '') {
							return;
						}
						if (oObject[sChild] === true) {
							aFilters.push((sName ? sName + '/' : '') + sChild);
						} else if (typeof oObject[sChild] === 'object') {
							collect((sName ? sName + '/' : '') + sChild, oObject[sChild]);
						}
					});
				}
			}

			if (this.get(oObject, '/')) {
				return true;
			}

			collect('', oObject);

			return (aFilters.length > 0 ? aFilters.join(sSeparator || ',') : false);
		}
1156270
public function groupBy(callable $func)
    {
        $result = [];
        foreach ($this->each() as $k => $v) {
            $this->_groupBy($result, $k, $v, $func);
        }
        return $result;
    }
1080847
final public static function parMap($xs, $f, $n = 4, $timeout = null)
    {
        $parallel = new Internal\Parallel($f, $n, $timeout);
        $parallel->pushAll($xs);
        return $parallel;
    }
234240
public static function arrayFilterRecursive(Array $source, $fn)
    {
        $result = [];
        foreach ($source as $key => $value) {
            if (is_array($value)) {
                $result[$key] = static::arrayFilterRecursive($value, $fn);
                continue;
            }
            if ($fn($key, $value)) {
                $result[$key] = $value; // KEEP
                continue;
            }
        }

        return $result;
    }
1130678
public function map(callable $f) : NestableResult
    {
        return new self(
            $this->outer->map($f),
            array_map($f, $this->inner)
        );
    }
522886
public function previousAll(callable $callback = NULL) {
    $matches = [];
    foreach ($this->nodes as $node) {
      $matches = array_merge($matches, $node->previousAll($callback)->nodes);
    }
    return new NodeCollection($matches);
  }
757048
function collectUniqNodes(list, func) {
    var result = [];
    var nodeIds = {};
    var currentNodeId;

    flexiEach(list, function(value) {
      flexiEach(func(value), function(node) {
        if (!nodeIds[currentNodeId = getNodeId(node)]) {
          result.push(node);
          nodeIds[currentNodeId] = true;
        }
      });
    });
    return result;
  }
470410
def _get_fs(name, blade):
    '''
    
    '''
    _fs = []
    _fs.append(name)
    try:
        res = blade.file_systems.list_file_systems(names=_fs)
        return res.items[0]
    except rest.ApiException:
        return None
936890
def _collectAsArrow(self):
        
        with SCCallSiteSync(self._sc) as css:
            sock_info = self._jdf.collectAsArrowToPython()

        # Collect list of un-ordered batches where last element is a list of correct order indices
        results = list(_load_from_socket(sock_info, ArrowCollectSerializer()))
        batches = results[:-1]
        batch_order = results[-1]

        # Re-order the batch list using the correct order
        return [batches[i] for i in batch_order]
131361
public static function reciprocal(array $xs): array
    {
        $zeros = array_filter(
            $xs,
            function (float $x) {
                return $x == 0;
            }
        );
        if (!empty($zeros)) {
            throw new Exception\BadDataException('Cannot compute the reciprocal of 0');
        }

        return array_map(
            function ($x) {
                return 1 / $x;
            },
            $xs
        );
    }
1130343
final public static function take($xs, $n = null, $guard = null)
    {
        return static::first($xs, $n, $guard);
    }
272510
public function map(callable $f) : Result
    {
        $result = new self(array_map($f, $this->errors));
        $result->fatal = $this->fatal;

        return $result;
    }