You have problems, and we're glad to hear them. Explain the problem, what you have tried, and where you got stuck.
Feel free to share a little info on yourself and the course.
Please respect your teacher's guidelines. Homework is a learning tool. If we just post answers, we aren't actually helping. When you post questions, be sure to show what you have tried or what you don't understand.
- Posts: 3
- Joined: Wed Apr 25, 2012 12:36 am
I have a list
I have to do a function Order that has a list with 'n' atoms at entry, it must check if each atom of that list is contained in list L and order them according to the order specified in list L, if the atom is not part of the list L then the result will be displayed
Code: Select all
(Defun Order lst)
(SetQ L2'(w o 5 j 3))
I want to verify this:
result should return:
- Posts: 226
- Joined: Fri Aug 06, 2010 6:34 am
- Location: Germany
Sorry, but this forum is not called "we make your homework".
- Posts: 538
- Joined: Sat Aug 09, 2008 10:44 am
- Location: Newton, MA
I moved the topic to the homework forum. The source language is CL.
- Posts: 3
- Joined: Thu Mar 01, 2012 11:29 am
So this problem is designed to step through one list and at each atom check if it exists in the other.
This problem is asking you to make two recursive tasks, one based on L and one on L2. I suggest you start with L as it defines your order.
If null, return nil
else If L2 contains car L return car L
else call L's function with cdr L.
If L2 null, return nil
else if car L equals car L2 return car L2
else call L2's function with cdr L2
Put those two together and there you go.