diff options
Diffstat (limited to 'input.lisp')
-rw-r--r-- | input.lisp | 11 |
1 files changed, 11 insertions, 0 deletions
@@ -18,3 +18,14 @@ (defun cursor-distance (input1 input2) (- (input-cursor input1) (input-cursor input2))) + +(defun line-and-column (input) + (let ((line 1) (column 1)) + (dotimes (i (input-cursor input)) + (let ((c (char (input-data input) i))) + (case c + (#\Newline + (incf line) + (setf column 1)) + (t (incf column))))) + (values line column))) |