Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #4852
| From | Alan <alan.isaac@gmail.com> |
|---|---|
| Newsgroups | comp.soft-sys.math.mathematica |
| Subject | execution model: Function vs. delayed execution |
| Date | 2011-09-10 11:34 +0000 |
| Organization | Steven M. Christensen and Associates, Inc and MathTensor, Inc. |
| Message-ID | <j4fhvn$2gr$1@smc.vnet.net> (permalink) |
Warning: I am a Mathematica newbie and not a CS type, so my vocabulary may prove clumsy.
I am used to a deferred execution model of function definition. Roughly, if I can write code that would be successfully executed outside a function definition, then I can make it a function body by appropriately "wrapping" it.
In Mathematica, I can evaluate the following):
x = {1,1,2}
x=DeleteDuplicates[x]; x
(Note: the redundancy is intentional.)
Next, I attempt to "wrap" this as follows
Clear[x]
Function[x, (x=DeleteDuplicates[x];x)][{1,1,2}]
This produces an error:
Set::shape: "Lists {1,1,2} and {1,2} are not the same shape."
Can you help me understand the execution model that leads to this?
Thanks,
Alan Isaac
Back to comp.soft-sys.math.mathematica | Previous | Next — Next in thread | Find similar | Unroll thread
execution model: Function vs. delayed execution Alan <alan.isaac@gmail.com> - 2011-09-10 11:34 +0000
Re: execution model: Function vs. delayed execution David Bailey <dave@removedbailey.co.uk> - 2011-09-11 11:31 +0000
Re: execution model: Function vs. delayed execution "Oleksandr Rasputinov" <oleksandr_rasputinov@hmamail.com> - 2011-09-11 11:34 +0000
Re: execution model: Function vs. delayed execution Alan <alan.isaac@gmail.com> - 2011-09-12 08:25 +0000
csiph-web