home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / sci / math / symbolic / 2948 < prev    next >
Encoding:
Text File  |  1992-11-11  |  1.4 KB  |  45 lines

  1. Newsgroups: sci.math.symbolic
  2. Path: sparky!uunet!charon.amdahl.com!pacbell.com!ames!saimiri.primate.wisc.edu!zaphod.mps.ohio-state.edu!cs.utexas.edu!qt.cs.utexas.edu!yale.edu!jvnc.net!darwin.sura.net!mlb.semi.harris.com!widget!gsp
  3. From: gsp@mlb.semi.harris.com (Gary Porter,62B-384,7295697)
  4. Subject: Question about programming in mma
  5. Date: Wed, 11 Nov 1992 21:14:05 GMT
  6. Nntp-Posting-Host: widget.mlb.semi.harris.com
  7. Reply-To: gsp@mlb.semi.harris.com
  8. Organization: Harris Semiconductor Corporation
  9. Keywords: symbols mma
  10. Sender: news@mlb.semi.harris.com
  11. Message-ID: <1992Nov11.211405.27798@mlb.semi.harris.com>
  12. Lines: 31
  13.  
  14. Can someone tell me how to pass symbols as parameters
  15. in mathematica. (like nlambda or macros in lisp)
  16.  
  17. For example, I want to define a function "dropCar" that
  18. takes a symbol as a parameter and has the side-effect of setting the 
  19. symbol's value to the "rest" of it's list.
  20.  
  21.     dropCar[ symbol_ ] := Block[ {},
  22.         symbol = Rest[ symbol ] 
  23.     ]
  24.         
  25.     y = { 1.1, 2.2, 3.3 }
  26.  
  27. Such that:
  28.  
  29.     dropCar[ y ]
  30.  
  31. sets y to { 2.2, 3.3 }, and another:
  32.  
  33.     dropCar[ y ]
  34.  
  35. sets y to { 3.3 }
  36.  
  37. The above code doesn't work, do you know of a way to do this?
  38.  
  39. ---
  40. Gary Porter                            Principal Engineer
  41. Internet:  gsp@mlb.semi.harris.com     Harris Semiconductor
  42. Phone:     (407) 729-5697              PO Box 883   MS 62B-022
  43. FAX:       (407) 729-4960              Melbourne, FL  32902-0883
  44.  
  45.