code: func filter(rs []ast.Ref, pred func(ast.Ref, ast.Ref) bool) (filtered []ast.Ref) {
  	if len(rs) == 0 {
  		return nil
  	}
  
  	last := rs[0]
  	filtered = append(filtered, last)
  	for i := 1; i < len(rs); i++ {
  		cur := rs[i]
  		if pred(last, cur) {
  			continue
  		}
  
  		filtered = append(filtered, cur)
  		last = cur
  	}
  
  	return filtered
  }
docs: // filter removes all items from the list that cause pref to return true. It is
  // called on adjacent pairs of elements, and the one passed as the second argument
  // to pref is considered the current one being examined. The first argument will
  // be the element immediately preceding it.