[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.lisp

Re: debugging anonymous lambda forms

William James

5/17/2015 4:22:00 AM

Erik Naggum wrote:

> I prefer to use KEY and TEST keyword arguments that default to #'IDENTITY
> and #'EQL.
>
> (defun duplic8 (element list &key (test #'eql) (key #'identity))
> (loop for x in list
> collect x
> when (funcall test (funcall key x) element) collect x))

Gauche Scheme:

(use srfi-42 :only (append-ec))

(define (duplic8 element pool :key (test eqv?) (key identity))
(append-ec (: x pool)
(if (test (key x) element) (list x x) (list x))))


gosh> (duplic8 'b '(a b c))
(a b b c)

--
Blacks are an estimated 39 times more likely to commit a violent crime against
a white than vice versa, and 136 times more likely to commit robbery. ---
www.colorofcrime.com/2005/10/the-color-of-crime-2005/