Article View: sci.math.symbolic
Article #1092Re: A Mathematica question.
From: Phil Wayne
Date: Wed, 03 Aug 1988 21:09
Date: Wed, 03 Aug 1988 21:09
30 lines
1470 bytes
1470 bytes
In article <605@ndcheg.cheg.nd.edu> jeff@ndcheg.cheg.nd.edu (Jeffrey C. Kantor) writes:
>After spending the weekend doing Mathematica, I thought I would post a
>simple question. Suppose you want to replace every element of a list
>with a corresponding element of another list, i.e.,
>
>expr /. {a,b,c,d}->{1,2,3,4} (NOTE: NOT A VALID STATEMENT)
>
>where -> works on an element-by-element basis. What is the most efficient
>way of doing this? I hacked together a rather messy bit of code that is
>not very efficient. I was looking for a one-liner.
>
>This came up when trying to get the RungeKutta Notebook to work for a system
>of ODE's rather than a single ODE.
>
I hate to point this out but...
If both lists are the same length (which I assume they are) then if we have
x = { some list of elements... }
y = { some other list of elements of the same length as x... }
then the *EASY* *CHEAP* and *QUICK* way to do the replacement is...
(Ohhhh, god, how can I be this devious...)
x = y
Tah....Dahhhh
--- zardoz
Technical Details
Message-ID:
<15140@apple.Apple.COM>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!attcan!uunet!husc6!bloom-beacon!apple!zardozReferences:
<605@ndcheg.cheg.nd.edu>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!attcan!uunet!husc6!bloom-beacon!apple!zardoz From: zardoz@Apple.COM (Phil Wayne) Newsgroups: sci.math.symbolic,comp.sys.mac Subject: Re: A Mathematica question. Keywords: help Message-ID: <15140@apple.Apple.COM> Date: 3 Aug 88 21:09:45 GMT References: <605@ndcheg.cheg.nd.edu> Reply-To: zardoz@apple.apple.com.UUCP (Phil Wayne) Organization: Apple Computer Inc, Cupertino, CA Lines: 30