Code: Select all

```
(SetQ L '(1 j 3 k 4 h 5 n 6 w))
```

Code: Select all

```
(Defun Order lst)
(SetQ L2'(w o 5 j 3))
```

Code: Select all

`(Order L2)`

Code: Select all

`(J 3 5 W)`

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.

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

I want to verify this:

result should return:

Code: Select all

```
(SetQ L '(1 j 3 k 4 h 5 n 6 w))
```

Code: Select all

```
(Defun Order lst)
(SetQ L2'(w o 5 j 3))
```

Code: Select all

`(Order L2)`

Code: Select all

`(J 3 5 W)`

Sorry, but this forum is not called "we make your homework".

I moved the topic to the homework forum. The source language is CL.

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.

L's function:

If null, return nil

else If L2 contains car L return car L

else call L's function with cdr L.

L2's funciton:

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.

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.

L's function:

If null, return nil

else If L2 contains car L return car L

else call L's function with cdr L.

L2's funciton:

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.