I've been working on a project in common lisp for a bit now, and I can't figure out why the loop I am using won't return a list. It will print the new list (correctly!) if I use a 'Finally' statement at the end of the loop, but it will not print outside of it or let me use it for anything.
All of the examples I have found indicate that a return statement should do it, but still no dice when I try that. It just tells me meansList is undefined when I try to use it outside of the loop, and initializing it there doesn't work either.
The end goal is for the loop to return a list of the mean values for each set of data elements.
(defparameter data
' ((2.0 8.0) (0.9 1.2) (6.0 2.0)
(7.0 3.5) (4.0 6.0) (1.0 4.0)))
(loop for i in data
do (setq j (mean i)) collect j into meansList
finally (return (meansList))
The mean function returns the mean of a list. I have checked several times and that works as intended, though I could provide it here if necessary.