On Wed, 27 Jun 2012 05:29:11 -0400 Matthew Mondor <mm_li...@pulsar-zone.net> wrote:
> > (defun apropos (string &optional package) > > Alternate implementation: Yet another easy solution which instead returns sorted unique symbols in APROPOS-LIST (SBCL and CLISP do this): ;;; Original function renamed and documentation moved below (defun %apropos-list (string &optional package) (let* ((list '()) (string (string string))) (cond (package (dolist (p (package-use-list package)) (setf list (nconc (apropos-list string p) list))) (do-symbols (symbol package) (when (search string (string symbol) :test #'char-equal) (setq list (cons symbol list))))) (t (do-all-symbols (symbol) (when (search string (string symbol) :test #'char-equal) (setq list (cons symbol list)))))) list)) (defun apropos-list (symbol &optional package) "Args: (string &optional (package nil)) Returns a list of all symbols whose print-names contain STRING as substring. If PACKAGE is non-NIL, then only the specified PACKAGE is searched." (loop with dupes = (sort (%apropos-list symbol package) #'(lambda (a b) (string-lessp (prin1-to-string a) (prin1-to-string b)))) for prec = nil then item for item in dupes unless (and prec (eq prec item)) collect item)) ;;; Original unmodified function (defun apropos (string &optional package) "Args: (string &optional (package nil)) Prints those symbols whose print-names contain STRING as substring. If PACKAGE is non-NIL, then only the specified PACKAGE is searched." (setq string (string string)) (mapc #'print-symbol-apropos (apropos-list string package)) (values)) -- Matt ------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ Ecls-list mailing list Ecls-list@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/ecls-list