MathGroup Archive 1998

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

Search the Archive

Re: programming in Mathmatica

John M. Dlugosz wrote in message <6p6rtm$5me at>...
>Consider this function:
>(*1*) ackPrim[m_Integer, 0] := (
>(*2*) ++counter;
>(*3*) {result_,rc_ } -> cAck[m-1,1]; (*4*) { result, rc+1 }
>(*5*) );
>The function cAck returns a list of two items.  In Perl I write:
> my ($result, $rc) = cAck ($m-1, 1);


Set and  SetDelayed are listable, for example

{f[x_/;x>4],{g[y_],z}} = {1,{2/;y>3,{3}}};

The assingments stored are

?f g z
f[x_ /; x > 4] = 1
g[y_] = 2 /; y > 3
z = {3}

Similarly with SetDelayed (:=)

>Next, you see I'm using a list of two values.  For more complex
>programs,  such "structures" represented as lists would get a little
>awkward.  I can  imagine using access functions to pull the correct
>member of a list, so I  get the benifit of named structure members, and
>even creating an operator  for that which works similarly to the "dot"
>in Algol-decendent languages.   So, I assume people have done this
>already and there is a standard idiom  in circulation for it.  What is
>it, so I don't have to re-invent my own?
>=> What is the standard practice for using what other languages do with

Could you give some Mathematica examples of what you want to do please.


------------------------------------------------------------- Allan
Training and Consulting
Leicester UK
hay at
voice: +44 (0)116 271 4198
fax: +44(0)116 271 8642

  • Prev by Date: Re: Re: Is this a bug?
  • Next by Date: Re: polar coordinates
  • Previous by thread: programming in Mathmatica
  • Next by thread: partially delayed evaluation