home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / lang / function / 1370 next >
Encoding:
Text File  |  1992-11-14  |  1.9 KB  |  60 lines

  1. Newsgroups: comp.lang.functional
  2. Path: sparky!uunet!psgrain!percy!hfglobe!ichips!iWarp.intel.com|eff!sol.ctr.columbia.edu!zaphod.mps.ohio-state.edu!cs.utexas.edu!sun-barr!ames!agate!dog.ee.lbl.gov!hellgate.utah.edu!csn!teal.csn.org!sullivan
  3. From: sullivan@teal.csn.org (Steve Sullivan)
  4. Subject: ml questions
  5. Message-ID: <BxrLL9.A11@csn.org>
  6. Sender: news@csn.org (news)
  7. Nntp-Posting-Host: teal.csn.org
  8. Organization: Colorado SuperNet, Inc.
  9. Date: Sun, 15 Nov 1992 15:55:56 GMT
  10. Lines: 48
  11.  
  12.  
  13. I'm enjoying learning sml, and had a few
  14. questions.  Please let me know if you can shed
  15. any light on any of these!  Many thanks ...
  16.  
  17.  
  18. 1. The sml I'm using, from princeton.edu, includes Harper's notes.
  19. His notes document the "system" and "cd" commands.
  20. Yet sml apparently doesn't recognize them.  How can I get them working?
  21.  
  22.  
  23. 2.  How can I get a function to remember state?
  24.  
  25. In particular, I want to write a random number
  26. generator that remembers it's last seed,
  27. so the caller doesn't have to provide it.  Many modern
  28. generators require hundreds of bytes of state info, so passing
  29. that in and out on each call is very inefficient.
  30.  
  31. Simple example - how to get sml to do something like:
  32.  
  33. fun rand 1 = let val seed = ref 1 in !seed end   (* initialize and return 1 *)
  34.   | rand 2 = (seed := (xx*seed) mod yy; !seed;)  (* update seed, return it *)
  35.  
  36.  
  37. 3. Why not allow nonlinear patterns?  They wouldn't have to cover
  38. the whole general matching problem - just allow, for example,
  39.    fun (x,x) = ...
  40. to bind the first x, and then fail if the second x doesn't match.
  41.  
  42.  
  43.  
  44. 4. Why not lazy functions?  Seems lazy and strict evaluation
  45. could be mixed, with functions being lazy by default, and 
  46. strict if:
  47.   - they used any imperative features
  48.   - they used any function which is strict
  49. I looked at lsml from sbcs.sunysb.edu, but at first glance
  50. it seems very experimental and somewhat out of date.
  51.  
  52.  
  53. If you have light to shed on any of these, please let me
  54. know!  Many thanks -
  55.  
  56. Steve Sullivan
  57. sullivan@csn.org
  58.  
  59.  
  60.