This "awhen" macro... I cannot count how many time i had to use this mechanism and yet i never thought of doing a macro out of it, thanks for that too
Search found 4 matches
- Fri Nov 05, 2010 4:49 am
- Forum: Common Lisp
- Topic: moving an element of a list to another list
- Replies: 13
- Views: 13114
Re: moving an element of a list to another list
Thanks Warren for the suggestions, it was very interesting. I think it is always good to know more than one way to do something
This "awhen" macro... I cannot count how many time i had to use this mechanism and yet i never thought of doing a macro out of it, thanks for that too
This "awhen" macro... I cannot count how many time i had to use this mechanism and yet i never thought of doing a macro out of it, thanks for that too
- Fri Oct 29, 2010 9:57 am
- Forum: Common Lisp
- Topic: moving an element of a list to another list
- Replies: 13
- Views: 13114
Re: moving an element of a list to another list
Haven't you learned Lisp yet? :D I just started few days ago :) I tried the non-destructive one in my program, but i had problem with 'with-gensyms' so i modified it to : (defmacro pop-nth (n l) (let ((nvar (gensym)) (lvar (gensym)) (ncdr (gensym))) `(let* ((,nvar ,n) (,lvar ,l) (,ncdr (nthcdr ,nva...
- Fri Oct 29, 2010 12:33 am
- Forum: Common Lisp
- Topic: moving an element of a list to another list
- Replies: 13
- Views: 13114
Re: moving an element of a list to another list
Thanks Gugamilare, the first one look like what i was looking for. I was hoping there was a standard function that could help in this kind of case. Something like "pop" but which can work in the middle of a list. But now i realize that the "one way" nature of the lists makes this...
- Thu Oct 28, 2010 1:31 pm
- Forum: Common Lisp
- Topic: moving an element of a list to another list
- Replies: 13
- Views: 13114
moving an element of a list to another list
Let's say i need to remove the nth element of the list "l" and push it at the beginning of list "out". The best i could figure out is : (progn (push (nth n l) out) (setf l (delete (nth n l) l)) But it looks pretty inefficient to me. "(nth n l)" is evaluated twice and &q...