Newsgroups: comp.lang.lisp,comp.lang.misc
Path: cantaloupe.srv.cs.cmu.edu!europa.chnt.gtegsc.com!usenet.eel.ufl.edu!news.mathworks.com!news.duke.edu!news-server.ncren.net!concert!hearst.acc.Virginia.EDU!murdoch!usenet
From: "Steven D. Majewski" <sdm7g@Virginia.EDU>
Subject: Lisp & effeciency (was: An :apropos method for *object* )
In-Reply-To: <199506232101.AA17849@elvis.med.Virginia.EDU>
X-Sender: sdm7g@elvis.med.Virginia.EDU
X-Nntp-Posting-Host: elvis.med.virginia.edu
Content-Type: TEXT/PLAIN; charset=US-ASCII
Message-ID: <Pine.A32.3.90.950623192558.15172D-100000@elvis.med.Virginia.EDU>
To: kanderso@bbn.com
Sender: usenet@murdoch.acc.Virginia.EDU
Cc: Xlisp List <stat-lisp-news@umnstat.stat.umn.edu>
Organization: University of Virginia
Mime-Version: 1.0
Date: Fri, 23 Jun 1995 23:54:04 GMT
Lines: 57
Xref: glinda.oz.cs.cmu.edu comp.lang.lisp:18235 comp.lang.misc:22163


Thanks for the helpful comments. 
At end is (I hope) a better version (using builtin string-search).

On Fri, 23 Jun 1995 kanderso@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)  <sdm7g@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 ))))


