On Wed, 23 Apr 2008, Aykut Caglayan <[EMAIL PROTECTED]> writes:
> Ornegin soyle bir listem var:>'(0 1 1 0 0 1 1)
> ve ben su cevabi ariyorum:> '(1 2 5 6)
CL-USER> (defun positions (item list)
"POSITION derivate returns list of positions of the
supplied ITEM occuring in the specified LIST."
(labels ((collect-positions (position accum list)
(cond
((endp list) accum)
((eql item (first list))
(collect-positions (1+ position)
(cons position accum)
(rest list)))
(t (collect-positions (1+ position) accum (rest
list))))))
(nreverse (collect-positions 0 nil list))))
STYLE-WARNING: redefining POSITIONS in DEFUN
POSITIONS
CL-USER> (positions 1 '(0 1 1 0 0 1 1))
(1 2 5 6)
Ağız tadınıza uygun olarak KEY ve TEST seçeneklerini de -- POSITION
işlevinde olduğu gibi -- POSITIONS'a da ekleyebilirsiniz.
İyi çalışmalar.
_______________________________________________
cs-lisp mailing list
[email protected]
http://church.cs.bilgi.edu.tr/lcg
http://cs.bilgi.edu.tr/mailman/listinfo/cs-lisp