From: Salvador Gonzalez
Subject: Modify an argument
Date: 
Message-ID: <01bc4736$c8512b20$LocalHost@default>
I do the same question in another one message, but may be now it's more
clear:

This is what I need to do....

	I have to create a defun that takes a number and a list as arguments, the
function has to modify the list, doing:

		(setf List1 '(A B (C D (E F G (H)) I (J K L) M) N))     ; This is the
list
		(RemoveN 3 List1) 				  ; This is the function call
                        -> (A B (C D I M) N)                               
             ; The function return
		* List1						  ; Show the List1 value
		-> (A B (C D I M) N)				  ; The List1 must be modified !!!

           
	The RemoveN function has to eliminate all the 3 and biggers levels of the
List, I mean:

		(A B N)                   ; Level 1
                        
                        (C D I M)                 ; Level 2
		
		(E F G) and (J K L)   ; Level 3
                        
                        (H)                           ; Level 4

	I think this is better to see what I want....

                                                    |->Level 4
		(A B (C D (E F G (H)) I (J K L) M) N)
			   |________|   |_____| -> Level 3
                                |______________________| -> Level 2
                        |_____________________________| -> Level 1

	When I say Levels, I mean level of anidation IN the list, so (A) the atom
A is the level 1, if i do (A (B) ), the atom B is the level 2, because the
list (B) is a sublist....

	It's clear ????


	Thanks in advance..... Salva.. (Sorry about my english).
From: Rainer Joswig
Subject: Re: Modify an argument
Date: 
Message-ID: <joswig-ya023180001204972058400001@news.lavielle.com>
In article <···························@default>, "Salvador Gonzalez"
<······@arrakis.es> wrote:

> I do the same question in another one message, but may be now it's more
> clear:
> 
> This is what I need to do....

Is this your homework?

(setf list1 '(A
              B
              (C D (E F G (H)) I (J K L) M)
              N))

(defun remove-nth-level (level list)
  #| Insert your solution here |#)

My version needs 7 lines and 265 characters (due to the
descriptive variable names - different from the TCL/C/C++
foo^hlks).

(dotimes (i 5)
  (format t
          "~%~a ~a"
          i
          (remove-nth-level i list1)))

My solution gives:

0 NIL
1 (A B N)
2 (A B (C D I M) N)
3 (A B (C D (E F G) I (J K L) M) N)
4 (A B (C D (E F G (H)) I (J K L) M) N)

Don't be puzzled by trying to change the value of LIST1 inside your
function. Write a version without side effects and
then do (setf list1 (remove-nth-level 2 list1)) .

-- 
http://www.lavielle.com/~joswig/