Beruflich Dokumente
Kultur Dokumente
The value of i++ is the value of i before In 5]:= i=5 Printi++] Printi]
the increment is done. 5
6
The value of ++i is the value of i after In 6]:= i=5 Print++i] Printi]
the increment. 6
6
Web sample page from The Mathematica Book, Second Edition, by Stephen Wolfram, published by Addison-Wesley Publishing Company (hard-
cover ISBN 0-201-51502-4; softcover ISBN 0-201-51507-5). To order Mathematica or this book contact Wolfram Research: info@wolfram.com;
http://www.wolfram.com/; 1-800-441-6284.
1991 Wolfram Research, Inc. Permission is hereby granted for web users to make one paper copy of this page for their personal use. Further re-
production, or any copying of machine-readable files (including this one) to any server computer, is strictly prohibited.
292 2. Principles of Mathematica
You can use assignments to lists to In 11]:= {a, b, c} = {1, 2, 3} {b, a, c} = {a, c, b} {a, b, c}
permute values of variables in any way. Out 11]= {3, 1, 2}
When you write programs in Mathematica, you will sometimes find it convenient to take a list, and
successively add elements to it. You can do this using the functions PrependTo and AppendTo.
Web sample page from The Mathematica Book, Second Edition, by Stephen Wolfram, published by Addison-Wesley Publishing Company (hard-
cover ISBN 0-201-51502-4; softcover ISBN 0-201-51507-5). To order Mathematica or this book contact Wolfram Research: info@wolfram.com;
http://www.wolfram.com/; 1-800-441-6284.
1991 Wolfram Research, Inc. Permission is hereby granted for web users to make one paper copy of this page for their personal use. Further re-
production, or any copying of machine-readable files (including this one) to any server computer, is strictly prohibited.
2.4 Transformation Rules and Definitions 293
for example, of lists of length 2 at each level. When you have built up such a structure, you can always
reduce it to a single list using Flatten.
This sets up a nested list structure for w. In 15]:= w = {1} Do w = {w, k^2}, {k, 1, 4} ] w
Out 15]= {{{{{1}, 1}, 4}, 9}, 16}
Web sample page from The Mathematica Book, Second Edition, by Stephen Wolfram, published by Addison-Wesley Publishing Company (hard-
cover ISBN 0-201-51502-4; softcover ISBN 0-201-51507-5). To order Mathematica or this book contact Wolfram Research: info@wolfram.com;
http://www.wolfram.com/; 1-800-441-6284.
1991 Wolfram Research, Inc. Permission is hereby granted for web users to make one paper copy of this page for their personal use. Further re-
production, or any copying of machine-readable files (including this one) to any server computer, is strictly prohibited.