[plt-scheme] srfi 1 impl: delete-duplicates!, append! - bugs?

From: Jacob Matthews (jacobm at cs.uchicago.edu)
Date: Wed May 10 12:06:03 EDT 2006

Igor Mikhailov wrote:

> Hi, all!
> I can not understand, is these bugs or features?

Features. The append! and delete-duplicates! functions still _return_ 
the relevant result rather than mutating their argument into that result 
--- the difference between the ! versions and the non-! versions is that 
the ! versions are allowed to mutate their arguments however they'd like 
in the process (presumably to make them faster or more memory-efficient).

Once you run one of these ! functions on a list, you can no longer trust 
that list to be anything in particular; you should just discard it and 
use the function's return value instead. So in general, if you want to 
use the ! version of one of these functions, use the pattern:

(set! a (remove-duplicates! a))
(set! b (append! b '(2 3 4))


Posted on the users mailing list.