chrome/tools/history-viz.py
def ClusterBy(objs, pred):
  """Group a list of objects by a predicate.

  Given a list of objects and a predicate over the objects, return a
  dictionary mapping pred(obj) -> all objs with the same pred(obj)."""
  clusters = {}
  for obj in objs:
    cluster = pred(obj)
    clusters[cluster] = clusters.get(cluster, [])
    clusters[cluster].append(obj)
  return clusters
Group a list of objects by a predicate.

  Given a list of objects and a predicate over the objects, return a
  dictionary mapping pred(obj) -> all objs with the same pred(obj).
Group a list of objects by a predicate.
Given a list of objects and a predicate over the objects, return a
dictionary mapping pred(obj) -> all objs with the same pred(obj).
Group a list of objects by a predicate . Given a list of objects and a predicate over the objects return a dictionary mapping pred ( obj ) - > all objs with the same pred ( obj ) .
def ClusterBy(objs, pred):
  clusters = {}
  for obj in objs:
    cluster = pred(obj)
    clusters[cluster] = clusters.get(cluster, [])
    clusters[cluster].append(obj)
  return clusters
def ClusterBy ( objs , pred ) : clusters = { } for obj in objs : cluster = pred ( obj ) clusters [ cluster ] = clusters . get ( cluster , [ ] ) clusters [ cluster ] . append ( obj ) return clusters
Group a list of objects by a predicate.
Group a list of objects by a predicate .
"""Group a list of objects by a predicate.

  Given a list of objects and a predicate over the objects, return a
  dictionary mapping pred(obj) -> all objs with the same pred(obj)."""
objs
pred