help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Element-Relative Sequence Insertion


From: Marc Tfardy
Subject: Re: Element-Relative Sequence Insertion
Date: Thu, 11 Jun 2009 17:01:09 +0200
User-agent: Thunderbird 2.0.0.21 (Windows/20090302)

>>> It does, but you have to decrypt it first.
>> (defun insert-after (elt lst new)
>>   (cond ((null lst)
>>          '())
>>         ((eq new (car lst))
>>          (cons (car lst) (cons elt (cdr lst))))
>>         (t
>>          (cons (car lst) (insert-after elt (cdr lst) new)))))
>>
>> (defun insert-before (elt lst new)
>>   (cond ((null lst)
>>          '())
>>         ((eq new (car lst))
>>          (cons elt lst))
>>         (t
>>          (cons (car lst) (insert-before elt (cdr lst) new)))))
>>
>> What is the price? ;-)
>
> What's the point in renaming the parameters and introducing bugs?
>
> Check again the order of the parameters!

OK, this was a mistake. But it's "only" cosmetics ;-) I tested this
with:

(insert-after 'X '(a b c) 'b)
(a b X c)

(insert-before 'X '(a b c) 'b)
(a X b c)

so I unintended assumed your right arguments order ;)


> Notice that (eq 3.141592 3.141592) --> nil ; which is the reason why
> eql should be used by default.

Yes, this was my big fault. Sorry.


> And bad points for not being able to use rot13.
>
> You lose.   :-)

Oh shit... :-)

regards
Marc




reply via email to

[Prev in Thread] Current Thread [Next in Thread]