pass by reference
- To: mathgroup at smc.vnet.net
- Subject: [mg93685] pass by reference
- From: juan flores <juanfie at gmail.com>
- Date: Sat, 22 Nov 2008 06:09:55 -0500 (EST)
Dear all, How do you pass by reference in Mathematica? Let us say we want to program push and pop. -------- Push[el_, stack_] := Prepend[stack, el] Pop[stack_] := {First[stack], Rest[stack]} stack = {1, 2, 3}; newel = 5; stack = Push[newel, stack] {5, 1, 2, 3} {lastel, stack} = Pop[stack] {5, {1, 2, 3}} stack {1, 2, 3} -------- Code is working, but it is kind of awkward to have to use pure functional programming. I have not been able to find the way to pass parameters by reference (or name - i.e. macros). Any pointers/ideas will be greatly appreciated. Have a good one, Juan Flores
- Follow-Ups:
- Re: pass by reference
- From: Sseziwa Mukasa <mukasa@jeol.com>
- Re: pass by reference