simple list question
Posted: Fri Oct 23, 2009 6:01 pm
hello all,
I'm new to lisp and was making a simple program.
4 lists with classes of 4 different students
1 list wit the names of the 4 lists
so to display all the classes from all the students i used a dolist function inside a do list function.
when i do this.. i get the error:
- ENDP: A proper list must not end with STUDENT1
i figure this is because lisp thinks that student1 is a string and not a list. is there a way that i can tell lisp that the string is the actually a list.
(setf student1 '((Math 320) (Itec 305) (Csci 355) (Csci 330) (Math 460) (Ieng 245))) ;List of my classes
(setf student2 '((Math 120) (Itec 205) (Csci 205) (Ieng 245))) ;List of first made up student
(setf student3 '((Math 350) (Csci 355) (Csci 330) (Math 460))) ;List of Second made up student
(setf student4 '((Math 320) (Csci 400) (Csci 200) (Math 120) (Ieng 332))) ;List of third made up student
(setf allStudents (student1 student2 student3 student4)) ;List of all 4 students
(defun showClass(cname) ;Show all courses of a subject
(dolist (studentName allStudents)
(dolist (subject studentName)
(print subject)
)
)
)
thanks for the future
Alex
I'm new to lisp and was making a simple program.
4 lists with classes of 4 different students
1 list wit the names of the 4 lists
so to display all the classes from all the students i used a dolist function inside a do list function.
when i do this.. i get the error:
- ENDP: A proper list must not end with STUDENT1
i figure this is because lisp thinks that student1 is a string and not a list. is there a way that i can tell lisp that the string is the actually a list.
(setf student1 '((Math 320) (Itec 305) (Csci 355) (Csci 330) (Math 460) (Ieng 245))) ;List of my classes
(setf student2 '((Math 120) (Itec 205) (Csci 205) (Ieng 245))) ;List of first made up student
(setf student3 '((Math 350) (Csci 355) (Csci 330) (Math 460))) ;List of Second made up student
(setf student4 '((Math 320) (Csci 400) (Csci 200) (Math 120) (Ieng 332))) ;List of third made up student
(setf allStudents (student1 student2 student3 student4)) ;List of all 4 students
(defun showClass(cname) ;Show all courses of a subject
(dolist (studentName allStudents)
(dolist (subject studentName)
(print subject)
)
)
)
thanks for the future
Alex