MathGroup Archive 2002

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

Search the Archive

RE: Assignments

  • To: mathgroup at
  • Subject: [mg36388] RE: [mg36295] Assignments
  • From: "DrBob" <drbob at>
  • Date: Wed, 4 Sep 2002 02:56:46 -0400 (EDT)
  • Reply-to: <drbob at>
  • Sender: owner-wri-mathgroup at

>>But my actual output reproduces the input form, i.e., it is simply

That means your arguments don't fit a pattern for which the function is
defined.  That is, it has nothing to do with what's on the right side of
":=".  It's about making sure there are the right number and type of
arguments passed to the function.  You haven't told us what the pattern
is or what the arguments are, so we can't help you.


-----Original Message-----
From: Thomas J. Fararo [mailto:tjf2+ at] 
To: mathgroup at
Subject: [mg36388] [mg36295] Assignments


         I am fairly new to Mathematica and once before asked a question
received some
very helpful responses.  This time the problem seems very odd and I may
making a very
elementary error.  Here is the context:

        I define a function of the form:

                              f[...,listA_, newEntry_,...]:= Which[...]

Here Which has the form of a set of  logically exclusive and exhausive
tests, each test with its own
action that modifies the concrete list subsituted for listA_.

        For instance, if there were only two tests the rhs above would
one that puts the newEntry
at the start of listA and the other that puts it at the end:

                             test1, listA = Insert[listA, newEntry, 1],
                             test2, listA = Insert[listA, newEntry, -1]

Then I try to use the function, substituting values for the arguments:
f[..., listA, newEntry, ...].  The
output should be the appropriately modified list.   But my actual output
reproduces the input form,
i.e., it is simply f[...listA,newEntry,...].

        Yet, the program does do something, as the use of "evaluate in

        Suppose that test1 is satisfied by the particular values of the
arguments.  Then when
I apply "evaluate in place" to the lhs of the action that is supposed to
occur when test1 is true,
in fact the value of Insert[listA,newEntry,1] is correct, but the rhs
only the initial value of
listA and not the modified value that is on the rhs.

       Concretely, suppose that in the function argument listA is {121}
newEntry is 200.
Then after evaluation of the function (input to the kernel), that line
reads, according to
"evaluate in place":

                                   true, {121} = {200, 121}

So it seems that only part of the correct action was taken: 200 was put
the start of listA. But
the assignment of this value -- the extended list -- to be the new value
listA did not take place.

 I then tried using a new name for the modified list, substituting this
program line for test1:

                                   test1, newListA = Insert[listA,

What I get here, applying "evaluate in place" after evaluating the
with concrete values as above

                                   true, newListA = {200, 121}

       Trace doesn't help because all I get back is the function name
its concrete arguments.

       Any thoughts?

                                   Thank you,

  • Prev by Date: Re: 3D plot -Reply
  • Next by Date: RE: Re: Re: Re: An interesting math problem
  • Previous by thread: Re: 3D plot - resend
  • Next by thread: Running Mathematica in background.