code / advent / 2024/00.lisp

1(defpackage #:advent.2024.00
2  (:use #:cl)
3  (:export #:vector->list
4           #:list->vector
5           #:input
6           #:with-input))
7(in-package #:advent.2024.00)
8
9;;; Utility functions and stuff
10
11(defun vector->list (v)
12  "Convert V, a one-dimensional vector or string, to a list."
13  (loop for el across v
14        collect el))
15
16(defun list->vector (l)
17  "Convert L to a vector."
18  (apply #'vector l))
19
20(defun input (&optional (package-designator *package*))
21  (format nil "~A.input" (subseq (package-name package-designator) 12)))
22
23(defmacro with-input (&body body)
24  `(let ((,(find-symbol "*INPUT*" *package*) (input)))
25     ,@body))