Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2010

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: something nice I found today, return multiple values from a function

  • To: mathgroup at smc.vnet.net
  • Subject: [mg113118] Re: something nice I found today, return multiple values from a function
  • From: Albert Retey <awnl at gmx-topmail.de>
  • Date: Wed, 13 Oct 2010 12:40:51 -0400 (EDT)
  • References: <i927an$3io$1@smc.vnet.net>

Hi,

> Opps, I was in middle of editing and pasted earlier version, here is the 
> final version:
> 
> ------------------
> getPointCoordinates[x_, y_] := Module[{}, {x -> 10, y -> 7}]
> 
> p = getPointCoordinates[x, y];
> x = x /. p;
> y = y /. p;
> 
> Print["x=", x]
> Print["y=", y]
> 
> x=10
> y=7
> 

1) I think it has been mentioned in another post today: Module with an
empty list is just an elaborate noop: You better just say:

 getPointCoordinates[x_, y_] := {x -> 10, y -> 7}

2) you also might like this:


makepoint[p_Symbol,xx_,yy_]:=(p[x]=xx;p[y]=yy; p);

makepoint[p,10,7]

p@x
p@y

hth,

albert


  • Prev by Date: Re: Tutorial for running remote kernels?
  • Next by Date: Re: Boolean factorization
  • Previous by thread: something nice I found today, return multiple values from a function
  • Next by thread: Re: something nice I found today, return multiple values from a function