This is the mail archive of the guile@cygnus.com mailing list for the guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Scheme style auto-resizing hashtable (fwd)


Jay Glascoe <jglascoe@jay.giss.nasa.gov> writes:

 > On Tue, 3 Nov 1998, Ian Bicking wrote:
 > > I think we have different notions of what dictionary-map should do.
 > > IMHO it should return a dictionary.  Just like map is a function that
 > > transforms one list into another, dictionary-map should transform one
 > > dictionary into another.
 > 
 > woh.  I didn't even think of that.  Let me take a look at some other
 > functional languages (Haskell and ML) and see what they do.
 > 
 > your suggestion makes "map" and "foreach" more consistent wrt each other.

The Common Lisp map fcn takes as 1st argument the kind of object to
return:

   >(map 'string #'(lambda (x) (character x)) '(71 72 73 74 75))
   "GHIJK"

   >(map 'list #'(lambda (x) (character x)) '(71 72 73 74 75))
   (#\G #\H #\I #\J #\K)

   >(map 'array #'(lambda (x) (character x)) '(71 72 73 74 75))
   #(#\G #\H #\I #\J #\K)

   >(map 'string #'(lambda (x) x) "abcde")    
   "abcde"

   >(map 'list #'(lambda (x) x) "abcde")    
   (#\a #\b #\c #\d #\e)

   >(map 'array #'(lambda (x) x) "abcde")    
   #(#\a #\b #\c #\d #\e)

-- 
Harvey J. Stein
BFM Financial Research
hjstein@bfr.co.il