Skip to content

Instantly share code, notes, and snippets.

View johnw42's full-sized avatar

John Williams johnw42

  • Microsoft
  • Seattle
  • 13:13 (UTC -07:00)
View GitHub Profile
from itertools import takewhile
from typing import Iterable, Sequence, TypeVar
T = TypeVar("T")
def common_prefix(seqs: Iterable[Sequence[T]]) -> Iterable[T]:
"Returns the common prefix of a sequence of sequences."
return (c[0] for c in takewhile(lambda x: all(x[0] == y for y in x), zip(*seqs)))
;;;###autoload
(defun before-compile-hook (&rest _)
"Saves the current buffer if it is associated with a file."
(interactive)
(when buffer-file-name
(save-buffer)))
(provide 'before-compile-hook)