(defpackage #:calorie-count
(:use :cl))
(in-package #:calorie-count)
(defvar calorie-list (list '()))
(with-open-file (s "/tmp/list")
(loop for line = (read-line s nil)
while line do (
if (string= line "")
(setf calorie-list (cons '() calorie-list))
(let ((x (car calorie-list)) (y (cdr calorie-list)))
(setf x (cons (parse-integer line) x))
(setf calorie-list (cons x y))))))
(defun max-index (max-val vals start-index)
(let ((val (car vals)) (vals (cdr vals)))
(cond ((not val) nil)
((eql val max-val) start-index)
(t (max-index max-val vals (1+ start-index))))))
(print calorie-list)
(let ((elf-list ((mapcar #'(lambda (l) (reduce #'+ l)) (reverse calorie-list))))
(let ((max-elf (apply #'max elf-list)))
(progn (print max-elf)
(let ((cnt 0))
(print (max-index max-elf elf-list 1))