home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / sci / math / symbolic / 2958 < prev    next >
Encoding:
Internet Message Format  |  1992-11-12  |  1.4 KB

  1. Path: sparky!uunet!charon.amdahl.com!pacbell.com!ames!ncar!noao!arizona!arizona.edu!cerritos.edu!news.service.uci.edu!beckman.com!dn66!a_rubin
  2. From: a_rubin@dsg4.dse.beckman.com (Arthur Rubin)
  3. Newsgroups: sci.math.symbolic
  4. Subject: Re: Question about programming in mma
  5. Keywords: symbols mma
  6. Message-ID: <a_rubin.721589449@dn66>
  7. Date: 12 Nov 92 17:30:49 GMT
  8. References: <1992Nov11.211405.27798@mlb.semi.harris.com>
  9. Organization: Beckman Instruments, Inc.
  10. Lines: 31
  11. Nntp-Posting-Host: dn66.dse.beckman.com
  12.  
  13. In <1992Nov11.211405.27798@mlb.semi.harris.com> gsp@mlb.semi.harris.com (Gary Porter,62B-384,7295697) writes:
  14.  
  15. >Can someone tell me how to pass symbols as parameters
  16. >in mathematica. (like nlambda or macros in lisp)
  17.  
  18. >For example, I want to define a function "dropCar" that
  19. >takes a symbol as a parameter and has the side-effect of setting the 
  20. >symbol's value to the "rest" of it's list.
  21.  
  22. >    dropCar[ symbol_ ] := Block[ {},
  23. >        symbol = Rest[ symbol ] 
  24. >    ]
  25. >        
  26. >    y = { 1.1, 2.2, 3.3 }
  27.  
  28. >Such that:
  29.  
  30. >    dropCar[ y ]
  31.  
  32. >sets y to { 2.2, 3.3 }, and another:
  33.  
  34. >    dropCar[ y ]
  35.  
  36. >sets y to { 3.3 }
  37.  
  38. SetAttributes[dropCar,HoldAll]
  39. --
  40. Arthur L. Rubin: a_rubin@dsg4.dse.beckman.com (work) Beckman Instruments/Brea
  41. 216-5888@mcimail.com 70707.453@compuserve.com arthur@pnet01.cts.com (personal)
  42. My opinions are my own, and do not represent those of my employer.
  43. My interaction with our news system is unstable; please mail anything important.
  44.