On 7/21/2024 7:56 PM, HenHanna wrote:
On 7/20/2024 5:21 PM, B. Pym wrote:
B. Pym wrote:
Pascal Costanza wrote:
(defun rem-duplicates (list)
(loop for (first . rest) on (append list list)
unless (member first (reverse rest) :test #'equal)
collect first))
Gauche Scheme
(define (rem-dups lst)
(fold
(lambda (x accum) (if (member x accum) accum (cons x accum)))
'()
lst))
(rem-dups '(0 2 3 4 (8 7) 3 2 0 (8 7)))
===>
(4 3 2 0 (8 7))
Actual result:
((8 7) 4 3 2 0)
Gauche doesn't have RemDup built in?
i remember that ... Rember was one of the 1st
exercises in intro to Lisp
Maybe there was a naming convention that suggested
that ... Delete is destructive and Remove is not.
_________________________________________________________
delete x list :optional elt= [Function]
delete! x list :optional elt= [Function]
[R7RS list] Equivalent to
(remove (lambda (y) (elt= x y)) list)
(remove! (lambda (y) (elt= x y)) list)
The comparison procedure, elt=, defaults to equal?.
delete-duplicates list :optional elt= [Function]
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)