From: Steven D. Majewski
Subject: Lisp & effeciency (was: An :apropos method for *object* )
Date: 
Message-ID: <Pine.A32.3.90.950623192558.15172D-100000@elvis.med.Virginia.EDU>
Thanks for the helpful comments. 
At end is (I hope) a better version (using builtin string-search).

On Fri, 23 Jun 1995 ········@bbn.com wrote:
( correcting my sloppy xlisp code) 
> 
> MAPCAR also conses a list unnecessarily here.
> 

Good advice, which leads me to an editorial comment: 
  Richard Gabriel has said that it's easy to program in Lisp but it's
difficult to program *WELL*. ( My poorly remembered paraphrase of 
his actual words. ) This could be a good example of what he might
have meant. It seems that the very features that make lisp natural 
and easy to use ( like mapping ) are often the very ones you should 
stay away from if you want effecient code! 
  At least I now understand why SML's 'map' returns a new function that
can be applied to a list, rather than returning a new list - that and
'o' (compose) would seem to encourage a simple, natural, function style, 
rather than penalizing it. 
  I suppose the ideal would be a language where you could more effectively
and separately express what-gets-done vs. how!


[ This message also posted to comp.lang.lisp & comp.lang.misc  - 
  so that any general pro/con lisp replies can go there, rather
  than on xlisp-stat mailing list. ( There has been a recent thread
  in comp.lang.lisp et.al. on why lisp is sometimes considered a 
  difficult language by some folks. ) ] 

[ :apropos gets rid of the excess consing of the previous version,
  but :apropos-list shamelessly does it the natural but ineffecient
  way! ;-) ] 

---|  Steven D. Majewski   (804-982-0831)  <·····@Virginia.EDU>  |---
---|  Computer Systems Engineer          University of Virginia  |---
---|  Department of Molecular Physiology and Biological Physics  |---
---|  Box 449 Health Science Center    Charlottesville,VA 22908  |---

( defmeth *object* :apropos ( str &key help )
 ( dolist 
    ( name ( send self :doc-topics ))
    ( when (string-search  str (symbol-name name)) 
           ( if help 
                ( progn ( send self :help name ) (terpri))
                (format t "~s~%" name )))))

    
( defmeth *object* :apropos-list ( str ) 
  (remove 
   Nil
   ( mapcar
     #'(lambda (x) (if (string-search str (symbol-name x)) x )) 
     ( send self :doc-topics ))))