MathProgrammingIntro.pdf
(
3406 KB
)
Pobierz
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
Mathematica
Ò
programming: an
advanced introduction
Leonid Shifrin
Part I: The core language
Version 1.01
2
3
To my parents
4
Contents
Preface.......................................................................................18
I. Introduction..............................................................................26
1.1 First principle: everything is an expression................................................................26
1.1.1 Atoms and the built-in AtomQ predicate......................................................................26
1.1.2
Mathematica
normal (composite) expressions............................................................26
1.1.3 Literal equivalents of built-in functions, and FullForm command................................26
1.1.4. All normal expressions are trees - TreeForm command............................................ .27
1.1.5. Heads of expressions and the Head command...........................................................27
1.1.6 Accessing individual parts of expressions through indexing ......................................28
1.1.7 Levels of expressions and the Level command...........................................................28
1.2 Second principle: pattern-matching and rule substitution...........................................30
1.2.1 Rewrite Rules..............................................................................................................30
1.2.2 An example of a simple pattern-defined function........................................................30
1.2.3 Functions are really rules : DownValues command....................................................31
1.2.4 Example of a function based on a restricted pattern...................................................31
1.2.5 A bit about evaluation..................................................................................................31
1.2.6 Patterns allow for multiple definitions of the same function.........................................31
1.2.7 Non - commutativity of rules substitution.....................................................................32
1.2.8 Automatic rule reordering.............................................................................................32
1.3 Third principle: expression evaluation........................................................................33
Summary...............................................................................................................................33
II. Elementary operations..............................................................34
2.1 Introduction..................................................................................................................34
2.2 Symbols and variables............................................................................................. ..34
2.2.1 Legitimate symbol names............................................................................................. 34
5
2.2.2 Getting information about symbols.................................................................................35
2.2.3 "Proper" variables and OwnValues.................................................................................36
2.2.4 Indexed variables and DownValues................................................................................36
2.2.5 Composite variables and SubValues..............................................................................37
2.2.6 Clearing variables...........................................................................................................37
2.2.7 Does a variable have a value? ValueQ.......................................................................39
2.2.8 Assignments attach rules to Symbol-s...........................................................................39
2.2.9 Summary........................................................................................................................40
2.3 Dynamic data typing.......................................................................................................40
2.4 Assignments...................................................................................................................41
2.4.1 Immediate and delayed assignments: Set and SetDelayed...........................................41
2.4.2 The difference between Set and SetDelayed : an example...........................................41
2.4.3 Chain assignments.........................................................................................................42
2.4.4 Don’ t use SetDelayed with more than two arguments...................................................43
2.4.5 Set and SetDelayed : when which one is used...............................................................44
2.5 Equality checks............................................................................................................ ..44
2.5.1 Equal...............................................................................................................................44
2.5.2 Beware: Equal may return "unevaluated".......................................................................44
2.5.3 Equal is used by built-in solvers to build equations..........................................................45
2.5.4 Assigning the result of Equal to a variable, and more on evaluation..............................45
2.5.5 The role of side effects...................................................................................................46
2.5.6 A digression: standard and non-standard evaluation........................................................46
2.5.7 Pass by reference semantics - possible to imitate..........................................................47
2.5.8 SameQ............................................................................................................................47
2.5.9 TrueQ..............................................................................................................................48
2.6 Logical operators..........................................................................................................49
2.7 Conditionals...................................................................................................................50
2.7.1 The If operator................................................................................................................50
2.7.2 If may return "unevaluated"............................................................................................50
Plik z chomika:
Satoremihi7
Inne pliki z tego folderu:
bonk-0.6.tar.gz
(17 KB)
tera.7z
(2607 KB)
xvidcore-1.3.3.tar.gz
(799 KB)
last_x264.tar.bz2
(636 KB)
multicoreware-x265-e6b519dfbf81.zip
(890 KB)
Inne foldery tego chomika:
Pliki dostępne do 01.06.2025
Pliki dostępne do 16.11.2022
Pliki dostępne do 19.01.2025
Pliki dostępne do 19.04.2020
;)
Zgłoś jeśli
naruszono regulamin