aoc-2022/elisp/advent-of-code.el

38 lines
1.2 KiB
EmacsLisp

;; -*- lexical-binding: t; -*-
;; Copyright (C) 2022
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <https://www.gnu.org/licenses/>.
(defun aoc-read-file (file)
(with-temp-buffer
(insert-file-contents-literally file nil)
(decode-coding-string (buffer-substring-no-properties (point-min) (point-max)) 'utf-8)))
(defun aoc-read-file-lines (file &optional omit-nulls)
(string-lines (aoc-read-file file) omit-nulls))
(defmacro aoc-debug (expr)
`(let ((e ,expr))
(princ (format "%s\n\n" e) 'external-debugging-output)
(unless noninteractive
(debug e))
e))
(provide 'advent-of-code)
;; Local Variables:
;; read-symbol-shorthands: (("aoc-" . "advent-of-code-"))
;; End: