notebooks neu generiert

This commit is contained in:
Meik Hellmund 2024-04-08 14:20:54 +02:00
parent aa345eb7b1
commit 09c2d9a79b
14 changed files with 2745 additions and 1329 deletions

View File

@ -72,7 +72,7 @@ format:
highlight-style: github # arrow ?????
mainfont: "Roboto Condensed" # Ubuntu # "Atkinson Hyperlegible" # Verdana #Quicksand
toc: true # change for Vorlesung
toc: false # change for Vorlesung
toc-depth: 3
number-depth: 3
email-obfuscation: javascript

View File

@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "markdown",
"id": "29fd19a8",
"id": "7c21d452",
"metadata": {},
"source": [
"# Zeichen, Strings und Unicode\n",
@ -64,7 +64,7 @@
"- davon entfallen über 90 000 Zeichen auf die CJK-Schriften (Chinesisch/Japanisch/Koreanisch) \n",
" \n",
" \n",
"### technische Details\n",
"### Technische Details\n",
"\n",
"- Jedem Zeichen wird ein `codepoint` zugeordnet. Das ist einfach eine fortlaufende Nummer.\n",
"- Diese Nummer wird hexadezimal notiert\n",
@ -93,7 +93,7 @@
" - Laufrichtung der Schrift \n",
" - Kategorie: Großbuchstabe, Kleinbuchstabe, modifizierender Buchstabe, Ziffer, Satzzeichen, Symbol, Seperator,....\n",
"\n",
"Im Unicode-Standard sieht das dann so aus: (zur Vereinfachung nur Codepoint und Name)\n",
"Im Unicode-Standard sieht das dann so aus (zur Vereinfachung nur Codepoint und Name):\n",
"```\n",
"...\n",
"U+0041 LATIN CAPITAL LETTER A\n",
@ -117,7 +117,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "8eaf4a41",
"id": "48697b80",
"metadata": {},
"outputs": [],
"source": [
@ -126,7 +126,7 @@
},
{
"cell_type": "markdown",
"id": "1c1f742a",
"id": "568c932d",
"metadata": {},
"source": [
"### Eine Auswahl an Schriften \n",
@ -148,7 +148,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "823bfab7",
"id": "44eecb07",
"metadata": {},
"outputs": [],
"source": [
@ -165,7 +165,7 @@
},
{
"cell_type": "markdown",
"id": "50893728",
"id": "9857ec8a",
"metadata": {},
"source": [
"__Kyrillisch__\n"
@ -174,7 +174,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "8caca4e0",
"id": "d1827fb6",
"metadata": {},
"outputs": [],
"source": [
@ -183,7 +183,7 @@
},
{
"cell_type": "markdown",
"id": "4400710f",
"id": "1975b4c8",
"metadata": {},
"source": [
"__Tamilisch__\n",
@ -194,7 +194,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "85bb89e4",
"id": "0ac169a1",
"metadata": {},
"outputs": [],
"source": [
@ -205,7 +205,7 @@
},
{
"cell_type": "markdown",
"id": "3904378b",
"id": "cf47c3ec",
"metadata": {},
"source": [
"\\begingroup\\setmonofont{Noto Sans Tamil}\n"
@ -214,7 +214,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "13461be4",
"id": "4c539418",
"metadata": {},
"outputs": [],
"source": [
@ -225,7 +225,7 @@
},
{
"cell_type": "markdown",
"id": "e8ed18a7",
"id": "57b1dd19",
"metadata": {},
"source": [
"\\endgroup\n",
@ -238,7 +238,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "8f6b4cee",
"id": "6d474a65",
"metadata": {},
"outputs": [],
"source": [
@ -247,7 +247,7 @@
},
{
"cell_type": "markdown",
"id": "f9ca81ef",
"id": "9c31ea8a",
"metadata": {},
"source": [
"__Mathematische Operatoren__\n"
@ -256,7 +256,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "60c00c29",
"id": "58aaf4c5",
"metadata": {},
"outputs": [],
"source": [
@ -265,7 +265,7 @@
},
{
"cell_type": "markdown",
"id": "1e023c33",
"id": "9b6c63b0",
"metadata": {},
"source": [
"__Runen__\n"
@ -274,7 +274,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "361517d3",
"id": "88859f95",
"metadata": {},
"outputs": [],
"source": [
@ -283,7 +283,7 @@
},
{
"cell_type": "markdown",
"id": "067f18ed",
"id": "08203fd6",
"metadata": {},
"source": [
":::{.cellmerge}\n",
@ -298,7 +298,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "9ac8d6c5",
"id": "640c2422",
"metadata": {},
"outputs": [],
"source": [
@ -309,7 +309,7 @@
},
{
"cell_type": "markdown",
"id": "ab85dc8a",
"id": "ee56718c",
"metadata": {},
"source": [
"\\begingroup\\setmonofont{Phaistos.otf}\n"
@ -318,7 +318,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "599a342d",
"id": "0a728045",
"metadata": {},
"outputs": [],
"source": [
@ -329,7 +329,7 @@
},
{
"cell_type": "markdown",
"id": "c5ccd262",
"id": "cfcb78f6",
"metadata": {},
"source": [
"\\endgroup\n",
@ -376,7 +376,7 @@
"\n",
"Der Datentyp `Char` kodiert ein einzelnes Unicode-Zeichen. \n",
"\n",
"- Julia verwendet dafür einfachen Anführungszeichen: `'a'`. \n",
"- Julia verwendet dafür einfache Anführungszeichen: `'a'`. \n",
"- Ein `Char` belegt 4 Bytes Speicher und \n",
"- repräsentiert einen Unicode-Codepoint.\n",
"- `Char`s können von/zu `UInt`s umgewandelt werden und \n",
@ -392,7 +392,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "a8ea6e75",
"id": "707c245e",
"metadata": {},
"outputs": [],
"source": [
@ -401,7 +401,7 @@
},
{
"cell_type": "markdown",
"id": "ab924ce4",
"id": "ce463383",
"metadata": {},
"source": [
"- `Char`s können von/zu `UInt`s umgewandelt werden.\n"
@ -410,7 +410,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "dac49645",
"id": "6488fdf6",
"metadata": {},
"outputs": [],
"source": [
@ -420,7 +420,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "98bd57af",
"id": "2637de2b",
"metadata": {},
"outputs": [],
"source": [
@ -429,7 +429,7 @@
},
{
"cell_type": "markdown",
"id": "74470851",
"id": "985adab7",
"metadata": {},
"source": [
"__Bei einem Nicht-ASCII-String unterscheiden sich Anzahl der Bytes und Anzahl der Zeichen:__\n"
@ -438,7 +438,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "0edfc402",
"id": "53c741c8",
"metadata": {},
"outputs": [],
"source": [
@ -448,7 +448,7 @@
},
{
"cell_type": "markdown",
"id": "2c2ce448",
"id": "bf536c2d",
"metadata": {},
"source": [
"(Das Leerzeichen zählt natürlich auch.)\n"
@ -457,7 +457,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "c171aa8d",
"id": "37e36e85",
"metadata": {},
"outputs": [],
"source": [
@ -467,7 +467,7 @@
},
{
"cell_type": "markdown",
"id": "e0467145",
"id": "b9caf74d",
"metadata": {},
"source": [
"__Iteration über einen String iteriert über die Zeichen:__\n"
@ -476,7 +476,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "802e421f",
"id": "0e8e04e3",
"metadata": {},
"outputs": [],
"source": [
@ -487,7 +487,7 @@
},
{
"cell_type": "markdown",
"id": "b434c61b",
"id": "ce0cfd1b",
"metadata": {},
"source": [
"### Verkettung von Strings\n",
@ -500,7 +500,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "dba97090",
"id": "6f35d90f",
"metadata": {},
"outputs": [],
"source": [
@ -509,7 +509,7 @@
},
{
"cell_type": "markdown",
"id": "c2f3a520",
"id": "898a6ea1",
"metadata": {},
"source": [
"Damit sind auch Potenzen mit natürlichem Exponenten definiert.\n"
@ -518,7 +518,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "e8804720",
"id": "cb9d7217",
"metadata": {},
"outputs": [],
"source": [
@ -527,7 +527,7 @@
},
{
"cell_type": "markdown",
"id": "ffd0fd4c",
"id": "cc89a9ca",
"metadata": {},
"source": [
"### Stringinterpolation\n",
@ -539,7 +539,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "b8248a55",
"id": "16b8af0a",
"metadata": {},
"outputs": [],
"source": [
@ -551,7 +551,7 @@
},
{
"cell_type": "markdown",
"id": "b2039521",
"id": "1ddcc1ad",
"metadata": {},
"source": [
"### Backslash escape sequences \n",
@ -563,7 +563,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "f896516b",
"id": "64a50bab",
"metadata": {},
"outputs": [],
"source": [
@ -573,7 +573,7 @@
},
{
"cell_type": "markdown",
"id": "6258cdb2",
"id": "f8a758f6",
"metadata": {},
"source": [
"### Triple-Quotes\n",
@ -585,7 +585,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "e7913161",
"id": "a042c5ed",
"metadata": {},
"outputs": [],
"source": [
@ -600,7 +600,7 @@
},
{
"cell_type": "markdown",
"id": "15de1886",
"id": "7ff4c2dd",
"metadata": {},
"source": [
"### Raw strings\n",
@ -611,7 +611,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "a040859a",
"id": "929529cf",
"metadata": {},
"outputs": [],
"source": [
@ -621,7 +621,7 @@
},
{
"cell_type": "markdown",
"id": "6e24746e",
"id": "0040e4d6",
"metadata": {},
"source": [
"## Weitere Funktionen für Zeichen und Strings (Auswahl)\n",
@ -632,7 +632,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "f79e914f",
"id": "195a2a3e",
"metadata": {},
"outputs": [],
"source": [
@ -642,7 +642,7 @@
},
{
"cell_type": "markdown",
"id": "d39076f7",
"id": "2e50dae6",
"metadata": {},
"source": [
"### Anwendung auf Strings\n",
@ -653,7 +653,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "b6055040",
"id": "c778a4ad",
"metadata": {},
"outputs": [],
"source": [
@ -663,7 +663,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "29fd91ef",
"id": "6a162d83",
"metadata": {},
"outputs": [],
"source": [
@ -673,7 +673,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "73a589b9",
"id": "c2d57533",
"metadata": {},
"outputs": [],
"source": [
@ -682,7 +682,7 @@
},
{
"cell_type": "markdown",
"id": "5bdff431",
"id": "f6562800",
"metadata": {},
"source": [
"### Weitere String-Funktionen\n"
@ -691,7 +691,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "a24b1569",
"id": "495799ef",
"metadata": {},
"outputs": [],
"source": [
@ -702,7 +702,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "89003024",
"id": "13e4d303",
"metadata": {},
"outputs": [],
"source": [
@ -712,7 +712,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "01910748",
"id": "36451c74",
"metadata": {},
"outputs": [],
"source": [
@ -724,7 +724,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "d618c466",
"id": "a665d380",
"metadata": {},
"outputs": [],
"source": [
@ -734,7 +734,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "da05d6b9",
"id": "64967f02",
"metadata": {},
"outputs": [],
"source": [
@ -743,7 +743,7 @@
},
{
"cell_type": "markdown",
"id": "4e198e74",
"id": "663832cf",
"metadata": {},
"source": [
"## Indizierung von Strings\n",
@ -760,7 +760,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "4686b303",
"id": "23d51f20",
"metadata": {},
"outputs": [],
"source": [
@ -769,7 +769,7 @@
},
{
"cell_type": "markdown",
"id": "6c1a2fe1",
"id": "639c88fa",
"metadata": {},
"source": [
"Das erste Zeichen\n"
@ -778,7 +778,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "eb0e9898",
"id": "68ba5cb6",
"metadata": {},
"outputs": [],
"source": [
@ -787,7 +787,7 @@
},
{
"cell_type": "markdown",
"id": "50049fee",
"id": "44617a04",
"metadata": {},
"source": [
"Dieses Zeichen ist in UTF8-Kodierung 4 Bytes lang. Damit sind 2,3 und 4 ungültige Indizes. \n"
@ -796,7 +796,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "a6a3005a",
"id": "c4575cca",
"metadata": {},
"outputs": [],
"source": [
@ -805,7 +805,7 @@
},
{
"cell_type": "markdown",
"id": "5c428767",
"id": "e558202c",
"metadata": {},
"source": [
"Erst das 5. Byte ist ein neues Zeichen:\n"
@ -814,7 +814,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "29febb49",
"id": "3813bbdf",
"metadata": {},
"outputs": [],
"source": [
@ -823,7 +823,7 @@
},
{
"cell_type": "markdown",
"id": "0daa1973",
"id": "48f4cca9",
"metadata": {},
"source": [
"Auch bei der Adressierung von Substrings müssen Anfang und Ende jeweils gültige Indizes sein, d.h., der Endindex muss ebenfalls das erste Byte eines Zeichens indizieren und dieses Zeichen ist das letzte des Teilstrings. \n"
@ -832,7 +832,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "dbbc0c47",
"id": "546d4ed2",
"metadata": {},
"outputs": [],
"source": [
@ -841,7 +841,7 @@
},
{
"cell_type": "markdown",
"id": "b7fd7042",
"id": "1007a717",
"metadata": {},
"source": [
"Die Funktion `eachindex()` liefert einen Iterator über die gültigen Indizes:\n"
@ -850,7 +850,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "6e2b8427",
"id": "d01e440e",
"metadata": {},
"outputs": [],
"source": [
@ -862,7 +862,7 @@
},
{
"cell_type": "markdown",
"id": "f651e9bf",
"id": "2f35e6bf",
"metadata": {},
"source": [
"Wie üblich macht collect() aus einem Iterator einen Vektor.\n"
@ -871,7 +871,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "a591c148",
"id": "b1644ea5",
"metadata": {},
"outputs": [],
"source": [
@ -880,7 +880,7 @@
},
{
"cell_type": "markdown",
"id": "a7f9cb60",
"id": "dc77d9e5",
"metadata": {},
"source": [
"Die Funktion `nextind()` liefert den nächsten gültigen Index.\n"
@ -889,7 +889,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "d568dd47",
"id": "5c9f35e7",
"metadata": {},
"outputs": [],
"source": [
@ -898,7 +898,7 @@
},
{
"cell_type": "markdown",
"id": "91af5e34",
"id": "6d1e346b",
"metadata": {},
"source": [
"Warum verwendet Julia einen Byte-Index und keinen Zeichenindex? Der Hauptgrund dürfte die Effizienz der Indizierung sein.\n",
@ -913,7 +913,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "b62bbd82",
"id": "e1ec4807",
"metadata": {},
"outputs": [],
"source": [
@ -923,7 +923,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "93def2b5",
"id": "2f8520fd",
"metadata": {},
"outputs": [],
"source": [
@ -933,7 +933,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "e96565a7",
"id": "0f07cff3",
"metadata": {},
"outputs": [],
"source": [
@ -943,7 +943,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "e251544c",
"id": "19e5bcc4",
"metadata": {},
"outputs": [],
"source": [
@ -952,7 +952,7 @@
},
{
"cell_type": "markdown",
"id": "be81789e",
"id": "f614e688",
"metadata": {},
"source": [
"So kann man ab dem nächsten nach `n=5` gültigen Index weitersuchen:\n"
@ -961,7 +961,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "ad89b2c9",
"id": "3f3b90b4",
"metadata": {},
"outputs": [],
"source": [
@ -971,15 +971,9 @@
],
"metadata": {
"kernelspec": {
"display_name": "Julia 1.8.5",
"display_name": "Julia 1.10.2",
"language": "julia",
"name": "julia-1.8"
},
"language_info": {
"file_extension": ".jl",
"mimetype": "application/julia",
"name": "julia",
"version": "1.8.5"
"name": "julia-1.10"
}
},
"nbformat": 4,

View File

@ -2,35 +2,29 @@
"cells": [
{
"cell_type": "markdown",
"id": "2ffe347c",
"id": "32301000",
"metadata": {},
"source": [
"# Julia Dokumentation\n",
"# Arbeit mit Julia: REPL, Pakete, Introspection\n",
"\n",
"[https://docs.julialang.org/](https://docs.julialang.org/) die offizielle Dokumentation\n",
"\n",
"Einige Seiten mit Übersichten:\n",
"\n",
"## Dokumentation\n",
"\n",
"Die offizielle Julia-Dokumentation [https://docs.julialang.org/](https://docs.julialang.org/) enthält zahlreiche Übersichten, darunter:\n",
"\n",
" - [https://docs.julialang.org/en/v1/base/punctuation/](https://docs.julialang.org/en/v1/base/punctuation/) Verzeichnis der Symbole\n",
" - [https://docs.julialang.org/en/v1/manual/unicode-input/](https://docs.julialang.org/en/v1/manual/unicode-input/) Verzeichnis spezieller Unicode-Symbole und deren Eingabe in Julia via Tab-Vervollständigung\n",
" - [https://docs.julialang.org/en/v1/manual/mathematical-operations/#Rounding-functions](https://docs.julialang.org/en/v1/manual/mathematical-operations/#Rounding-functions) Liste mathematischer Funktionen \n",
"\n",
"---------\n",
"\n",
"\n",
"\n",
"# Hilfe und praktische Tipps\n",
"\n",
"----\n",
"\n",
"\n",
"## Julia REPL (Read - Eval - Print - Loop)\n",
"\n",
"Start von Julia in einem Terminal:\n",
"```\n",
"julia>\n",
"```\n",
"Nach dem Start von Julia in einem Terminal kann man neben Julia-Code auch verschiedene Kommandos eingeben \n",
"\n",
":::{.narrow}\n",
"| Kommando | Wirkung |\n",
"| :----------------------------| :------------------------ |\n",
"| `exit()` oder `Ctrl-d` | exit Julia |\n",
@ -40,28 +34,23 @@
"| `include(\"filename.jl\")` | Datei mit Julia-Code einlesen und ausführen |\n",
"\n",
"\n",
"-----\n",
"\n",
"Der REPL hat verschiedene Modi: \n",
"\n",
"| Modus | Prompt | Modus starten | Modus verlassen |\n",
"| :- | :- | :- | :- |\n",
"|||||\n",
"| default| `julia>` | | |\n",
"|||||\n",
"| default| `julia>` | | `Ctrl-d`|\n",
"| Package manager | `pkg>` | `]` | `backspace` |\n",
"|||||\n",
"| Help | `help?>` | `?`| `backspace `|\n",
"|||||\n",
"|Shell | `shell>` | `;` | `backspace`|\n",
"|||||\n",
"\n",
"--------\n",
":::\n",
"\n",
"\n",
"## Jupyter notebooks (IJulia)\n",
"## Jupyter-Notebooks (IJulia)\n",
"\n",
"Die Modi sind als Einzeiler in einer eigenen Input-Zelle nutzbar: \n",
"\n",
"In einem Jupyter-Notebook sind die Modi sind als Einzeiler in einer eigenen Input-Zelle nutzbar: \n",
"\n",
"(i) ein Kommando des Paket-Managers:\n"
]
@ -69,16 +58,17 @@
{
"cell_type": "code",
"execution_count": null,
"id": "d6c200e5",
"id": "efacde4f",
"metadata": {},
"outputs": [],
"source": [
"#| eval: false\n",
"] status "
]
},
{
"cell_type": "markdown",
"id": "9caf3630",
"id": "85fec425",
"metadata": {},
"source": [
"(ii) eine Help-Abfrage:\n"
@ -87,16 +77,17 @@
{
"cell_type": "code",
"execution_count": null,
"id": "c923aa16",
"id": "80535b76",
"metadata": {},
"outputs": [],
"source": [
"#| eval: false\n",
"?sin"
]
},
{
"cell_type": "markdown",
"id": "bfc75d15",
"id": "581aae68",
"metadata": {},
"source": [
"(iii) Ein Shell-Kommando:\n"
@ -105,44 +96,53 @@
{
"cell_type": "code",
"execution_count": null,
"id": "3617aff8",
"id": "c2438155",
"metadata": {},
"outputs": [],
"source": [
";ls .."
"#| eval: false\n",
";ls "
]
},
{
"cell_type": "markdown",
"id": "bdce3ab2",
"id": "bd2c64b7",
"metadata": {},
"source": [
"## Der Paket-Manager\n",
"## Der Paketmanager\n",
"\n",
"- Über 7000 Pakete, siehe [https://julialang.org/packages/](https://julialang.org/packages/)\n",
"- Bevor sie mit `using Module` verwendet werden können, müssen sie heruntergeladen und installiert werden.\n",
"- Dazu dient der `package manager`\n",
"- 2 Betriebsarten: \n",
" - als normale Julia-Anweisungen, die auch in einer `.jl`-Programmdatei stehen können:\n",
"Wichtiger Teil des _Julia Ecosystems_ sind die zahlreichen Pakete, die Julia erweitern.\n",
"\n",
"- Einige Pakete sind Teil jeder Julia-Installation und müssen nur mit einer `using Paketname`-Anweisung aktiviert werden. \n",
" - Sie bilden die sogenannte _Standard Library_ und dazu gehören \n",
" - `LinearAlgebra`, `Statistics`, `SparseArrays`, `Printf`, `Pkg` und andere.\n",
"- Über 9000 Pakete sind offiziell registriert, siehe [https://julialang.org/packages/](https://julialang.org/packages/). \n",
" - Diese können mit wenigen Tastendrücken heruntergeladen und installiert werden.\n",
" - Dazu dient der _package manager_ `Pkg`.\n",
" - Man kann ihn auf zwei Arten verwenden: \n",
" - als normale Julia-Anweisungen, die auch in einer `.jl`-Programmdatei stehen können:\n",
" ```\n",
" using Pkg\n",
" Pkg.add(\"TollesPaket\")\n",
" Pkg.add(\"PaketXY\")\n",
" ```\n",
" - im speziellen pkg-Modus des Julia-REPLs:\n",
" - im speziellen pkg-Modus des Julia-REPLs:\n",
" ```\n",
" ] add TollesPaket\n",
" ] add PaketXY\n",
" ```\n",
"----- \n",
" - Anschließend kann das Paket mit `using PaketXY` verwendet werden.\n",
"- Man kann auch Pakete aus anderen Quellen und selbstgeschriebene Pakete installieren.\n",
"\n",
"### Einige Funktionen\n",
" \n",
"### Einige Funktionen des Paketmanagers\n",
"\n",
"| Funktion | `pkg` - Mode | Erklärung |\n",
"|:------------------------|:----------------------|:----------------------------------------------------------|\n",
"|:------------------------|:--------------------------| :-------------------------------------------------------|\n",
"| `Pkg.add(\"MyPack\")` | `pkg> add MyPack` | add `MyPack.jl` to current environment |\n",
"| `Pkg.rm(\"MyPack\")` | `pkg> remove MyPack` | remove `MyPack.jl` from current environment |\n",
"| `Pkg.update()` | `pkg> update` | update packages in current environment |\n",
"| `Pkg.activate(\"mydir\")` | `pkg> activate mydir` | activate directory as current environment |\n",
"| `Pkg.status()` | `pkg> status` | list packages |\n",
"| `Pkg.instantiate()` | `pg> instantiate` | install all packages according to `Project.toml` |\n",
"\n",
"\n",
"### Installierte Pakete und Environments \n",
@ -152,308 +152,95 @@
" 2. eine Liste aller dabei auch als implizite Abhängigkeiten installierten Pakete in der Datei `Manifest.toml`. \n",
"- Das Verzeichnis, in dem diese Dateien stehen, ist das `environment` und wird mit `Pkg.status()` bzw. `]status` angezeigt. \n",
"- Im Normalfall sieht das so aus: \n",
"\n",
"```\n",
"(@v1.7) pkg> status\n",
" Status `~/.julia/environments/v1.7/Project.toml`\n",
"(@v1.8) pkg> status\n",
" Status `~/.julia/environments/v1.8/Project.toml`\n",
" [1dea7af3] OrdinaryDiffEq v6.7.1\n",
" [91a5bcdd] Plots v1.27.1\n",
" [438e738f] PyCall v1.93.1\n",
"```\n",
"\n",
"- Man kann für verschiedene Projekte eigene `environments` benutzen. Dazu kann man entweder Julia mit \n",
"```\n",
"```shell\n",
"julia --project=path/to/myproject\n",
"```\n",
"starten oder in Julia das environment mit `Pkg.activate(\"path/to/myproject\")` aktivieren. Dann werden `Project.toml, Manifest.toml` dort angelegt und verwaltet. (Die Installation der Paketdateien erfolgt weiterhin irgendwo unter `$HOME/.julia`) \n",
"\n",
"\n",
"### Zum Installieren von Paketen auf unserem Jupyter-Server `misun103`:\n",
"- Es gibt ein zentrales Repository, in dem alle von mir erwähnten Pakete bereits installiert sind. \n",
"\n",
"- Es gibt ein zentrales Repository, in dem alle in diesem Kurs erwähnten Pakete bereits installiert sind. \n",
"- Dort haben Sie keine Schreibrechte.\n",
"- Sie können aber zusätzliche Pakete in Ihrem `Home` installieren. Dazu ist als erster Befehl nötig, das aktuelle Verzeichnis zu aktivieren: \n"
"- Sie können aber zusätzliche Pakete in Ihrem `HOME` installieren. Dazu ist als erster Befehl nötig, das aktuelle Verzeichnis zu aktivieren: \n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "103bd8a1",
"id": "87138f78",
"metadata": {},
"outputs": [],
"source": [
"#| eval: false\n",
"] activate ."
]
},
{
"cell_type": "markdown",
"id": "077e93f2",
"id": "da9c6bb6",
"metadata": {},
"source": [
"(Man beachte den Punkt!)\n",
"\n",
"----\n",
"\n",
"Danach können Sie mit `add` im Pkg-Modus auch Pakete installieren:\n",
"\n",
"```\n",
"] add TollesPaket\n",
"```\n",
"\n",
"\n",
"Achtung! Das kann dauern! Viele Pakete haben komplexe Abhängigkeiten und lösen die Installation von weiteren Paketen aus. Viele Pakete werden beim Installieren vorkompiliert. Im REPL sieht man den Installationsfortschritt, im Jupyter-Notebook nicht.\n",
"\n",
"\n",
"## Eingebaute Hilfe und Informationen\n",
"Mit `?` und der `Tab`-Taste kommt man oft weiter. \n",
"\n",
"\n",
"\n",
"### weitere Hilfe: `@which`, `fieldnames()`, `methods()`, `names()`, `pwd()`\n"
"Danach können Sie mit `add` im Pkg-Modus auch Pakete installieren:\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "4f099673",
"id": "7a9e6ab0",
"metadata": {},
"outputs": [],
"source": [
"# Die Zuordnung zu einem Modul zeigt @which an:\n",
"\n",
"@which(sqrt)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "44276c0d",
"metadata": {},
"outputs": [],
"source": [
"# Die Komponenten einer struct oder eines anderen zusammengesetzten Typs:\n",
"\n",
"fieldnames(Rational)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "a200a34f",
"metadata": {},
"outputs": [],
"source": [
"fieldnames(Complex)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "d99bfda9",
"metadata": {},
"outputs": [],
"source": [
"# alle Methoden einer Funktion\n",
"\n",
"methods(sqrt)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "b3e6f127",
"metadata": {},
"outputs": [],
"source": [
"# alle Methoden einer Funktion bei bestimmten Argumenttypen. Die Argumenttypen müssen als Tupel angegeben werden\n",
"\n",
"methods(sqrt, (Number,)) # Komma nötig für 1-elementiges Tupel "
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "e74572ad",
"metadata": {},
"outputs": [],
"source": [
"# für einen Typ gibt methods() alle Konstruktoren aus\n",
"\n",
"methods(Int64)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "e4de6078",
"metadata": {},
"outputs": [],
"source": [
"# names(Module) gibt alle von einem Modul exportierte Namen aus. \n",
"# genau wie auch\n",
"#\n",
"# ?Module \n",
"#\n",
"# funktioniert es erst, wenn das Modul mit 'using Module' geladen ist.\n",
"# Oft ist es besser, wenn die using-Anweisung in einer eigenen Zelle steht.\n",
"\n",
"using Plots"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "f1df8377",
"metadata": {},
"outputs": [],
"source": [
"names(Plots)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "3654fab2",
"metadata": {},
"outputs": [],
"source": [
"# Julia kürzt den interaktiven Output. \n",
"# ein explizites print() zeigt alles:\n",
"\n",
"print(names(Plots))"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "dc9ca3b6",
"metadata": {},
"outputs": [],
"source": [
"# eine andere Möglichkeit der Ausgabe mit Überlänge in Jupyter\n",
"\n",
"show(stdout, MIME(\"text/plain\"), names(Plots))"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "9fa0f216",
"metadata": {},
"outputs": [],
"source": [
"# pwd() \"print working directory\" zeigt, in welchem Verzeichnis Julia gerade operiert. \n",
"#\n",
"# Wichtig für die Ein/Ausgabe mit Dateien, z.B. include()\n",
"\n",
"pwd()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "99c19918",
"metadata": {},
"outputs": [],
"source": [
"include(\"Jupyter.jl\") # Datei mit Julia-Code einlesen und abarbeiten"
"#| eval: false\n",
"] add PaketXY"
]
},
{
"cell_type": "markdown",
"id": "1464d951",
"id": "d5fc8aef",
"metadata": {},
"source": [
"## Informationen zu Typen\n",
"Achtung! Das kann dauern! Viele Pakete haben komplexe Abhängigkeiten und lösen die Installation von weiteren Paketen aus. Viele Pakete werden beim Installieren vorkompiliert. Im REPL sieht man den Installationsfortschritt, im Jupyter-Notebook leider nicht.\n",
"\n",
"### `subtypes()`, `supertypes()`, `typemax()`, `typemin()`, `fieldnames()`, `Base.return_types()`, `dump()`\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "1358c363",
"metadata": {},
"outputs": [],
"source": [
"subtypes(Real) # die letzten zwei sind durch das 'using Plots' dazugekommen"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "e35fb7da",
"metadata": {},
"outputs": [],
"source": [
"supertypes(Real)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "53be4687",
"metadata": {},
"outputs": [],
"source": [
"typemax(Int64), typemin(Int64), fieldnames(Complex)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "3a9ed940",
"metadata": {},
"outputs": [],
"source": [
"Base.return_types(sqrt, (Float64,))"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "207af4bd",
"metadata": {},
"outputs": [],
"source": [
"Base.return_types(sqrt, (Complex{Int64},))"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "66b42304",
"metadata": {},
"outputs": [],
"source": [
"# dump() zeigt alle Teile eines zusammengesetzten Objekts\n",
"\n",
"x = 3//4 + 75im\n",
"dump(x)"
]
},
{
"cell_type": "markdown",
"id": "9c6edfea",
"metadata": {},
"source": [
"## Der Julia JIT _(just in time)_ Compiler\n",
"\n",
"\n",
"\n",
"## Der Julia JIT _(just in time)_ Compiler: Introspection\n",
"\n",
"Julia baut auf die Werkzeuge des _LLVM Compiler Infrastructure Projects_ auf.\n",
"\n",
"\n",
":::{.narrow}\n",
"Stages of Compilation \n",
"\n",
"| stage & result | introspection command |\n",
"| :--- | :--- |\n",
"|Parse ==> Abstract Syntax Tree (AST) | `Meta.parse()` |\n",
"| Lowering: transform AST ==> Static Single Assignment (SSA) form | `@code_lowered`|\n",
"|Parse $\\Longrightarrow$ Abstract Syntax Tree (AST) | `Meta.parse()` |\n",
"| Lowering: transform AST $\\Longrightarrow$ Static Single Assignment (SSA) form | `@code_lowered`|\n",
"| Type Inference | `@code_warntype`, `@code_typed` |\n",
"| Generate LLVM intermediate representation | `@code_llvm`|\n",
"| Generate native machine code | `@code_native` |\n"
"| Generate native machine code | `@code_native` |\n",
"\n",
":::\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "4d433ab8",
"id": "bc5fdcec",
"metadata": {},
"outputs": [],
"source": [
@ -466,7 +253,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "de444d8a",
"id": "bb56b5a6",
"metadata": {},
"outputs": [],
"source": [
@ -476,27 +263,19 @@
{
"cell_type": "code",
"execution_count": null,
"id": "1ddf17aa",
"metadata": {},
"outputs": [],
"source": [
"using TreeView"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "70d267d7",
"id": "9a8825dd",
"metadata": {},
"outputs": [],
"source": [
"using TreeView\n",
"\n",
"walk_tree(p)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "b19b64ec",
"id": "aa2d2ada",
"metadata": {},
"outputs": [],
"source": [
@ -506,7 +285,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "57eb03f9",
"id": "e6303b02",
"metadata": {},
"outputs": [],
"source": [
@ -516,7 +295,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "cf273a25",
"id": "05f5a0cd",
"metadata": {},
"outputs": [],
"source": [
@ -526,7 +305,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "28779f6b",
"id": "523e86a5",
"metadata": {},
"outputs": [],
"source": [
@ -536,7 +315,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "02711d1f",
"id": "953d5e83",
"metadata": {},
"outputs": [],
"source": [
@ -546,15 +325,9 @@
],
"metadata": {
"kernelspec": {
"display_name": "Julia 1.8.5",
"display_name": "Julia 1.10.2",
"language": "julia",
"name": "julia-1.8"
},
"language_info": {
"file_extension": ".jl",
"mimetype": "application/julia",
"name": "julia",
"version": "1.8.5"
"name": "julia-1.10"
}
},
"nbformat": 4,

View File

@ -2,14 +2,14 @@
"cells": [
{
"cell_type": "markdown",
"id": "fcc03529",
"id": "81cc02aa",
"metadata": {},
"source": [
"# Container\n",
"\n",
"\n",
"Julia bietet eine große Auswahl von Containertypen mit weitgehend ähnlichem Interface an. \n",
"Wir stellen hier `Tuple`, `Range`, `Array`, `Vector` und `Matrix` vor. \n",
"Wir stellen hier `Tuple`, `Range` und `Dict` vor, im nächsten Kapitel dann `Array`, `Vector` und `Matrix`. \n",
"\n",
"Diese Container sind: \n",
"\n",
@ -21,9 +21,9 @@
"```julia\n",
"x = container[i]\n",
"``` \n",
"und einige sind \n",
"und einige sind auch \n",
"\n",
"- **mutierbar** (nur `Array`, `Vector` und `Matrix`): Man kann Elemente hinzufügen, entfernen und ändern.\n",
"- **mutierbar**: Man kann Elemente hinzufügen, entfernen und ändern.\n",
"\n",
"Weiterhin gibt es eine Reihe gemeinsamer Funktionen, z.B.\n",
"\n",
@ -41,7 +41,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "3b33212e",
"id": "ec893f0b",
"metadata": {},
"outputs": [],
"source": [
@ -54,7 +54,7 @@
},
{
"cell_type": "markdown",
"id": "e65e4da8",
"id": "21549769",
"metadata": {},
"source": [
"Ein Tupel ist ein **inhomogener** Typ. Jedes Element hat seinen eigenen Typ und das zeigt sich auch im Typ des Tupels:\n"
@ -63,7 +63,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "3d21cc5b",
"id": "5add8abb",
"metadata": {},
"outputs": [],
"source": [
@ -72,7 +72,7 @@
},
{
"cell_type": "markdown",
"id": "74fcc47e",
"id": "e8bc972e",
"metadata": {},
"source": [
"Man verwendet Tupel gerne als Rückgabewerte von Funktionen, um mehr als ein Objekt zurückzulieferen.\n"
@ -81,7 +81,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "6ffc0cdc",
"id": "85b3f1fd",
"metadata": {},
"outputs": [],
"source": [
@ -94,7 +94,7 @@
},
{
"cell_type": "markdown",
"id": "e7a04cdd",
"id": "d144679d",
"metadata": {},
"source": [
"Wie man hier sieht, kann man in bestimmten Konstrukten die Klammern auch weglassen.\n",
@ -104,7 +104,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "2a260b6e",
"id": "2ef18811",
"metadata": {},
"outputs": [],
"source": [
@ -114,7 +114,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "3447dffb",
"id": "759e8783",
"metadata": {},
"outputs": [],
"source": [
@ -123,7 +123,7 @@
},
{
"cell_type": "markdown",
"id": "8694ec4a",
"id": "2bed8606",
"metadata": {},
"source": [
"Manche Funktionen bestehen auf Tupeln als Argument oder geben immer Tupeln zurück. Dann braucht man manchmal ein Tupel aus einem Element. \n",
@ -134,7 +134,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "24856f9b",
"id": "e985c23d",
"metadata": {},
"outputs": [],
"source": [
@ -143,7 +143,7 @@
},
{
"cell_type": "markdown",
"id": "11ac465d",
"id": "174aed3a",
"metadata": {},
"source": [
"Das Komma - und nicht die Klammern -- macht das Tupel. \n"
@ -152,7 +152,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "87474e9d",
"id": "8359e689",
"metadata": {},
"outputs": [],
"source": [
@ -161,7 +161,7 @@
},
{
"cell_type": "markdown",
"id": "da35087d",
"id": "a5fb2b62",
"metadata": {},
"source": [
"## Ranges\n",
@ -172,7 +172,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "3bfc9415",
"id": "ba823baf",
"metadata": {},
"outputs": [],
"source": [
@ -182,7 +182,7 @@
},
{
"cell_type": "markdown",
"id": "7d2c6838",
"id": "6dd2ebf4",
"metadata": {},
"source": [
"Es gibt verschiedene *range*-Typen. Wie man sieht, sind es über den Zahlentyp parametrisierte Typen und `UnitRange` ist z.B. ein *range* mit der Schrittweite 1. Ihre Konstruktoren heißen in der Regel `range()`. \n",
@ -199,7 +199,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "28aecb9e",
"id": "5ee0a9ef",
"metadata": {},
"outputs": [],
"source": [
@ -208,7 +208,7 @@
},
{
"cell_type": "markdown",
"id": "350affb7",
"id": "f4524b63",
"metadata": {},
"source": [
"Wir erinnern an die Semantik der `for`-Schleife: `for i in 1:1000` heißt **nicht**:\n",
@ -228,7 +228,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "14ea84bd",
"id": "7049d454",
"metadata": {},
"outputs": [],
"source": [
@ -238,7 +238,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "c900fd32",
"id": "dbc66a57",
"metadata": {},
"outputs": [],
"source": [
@ -247,7 +247,7 @@
},
{
"cell_type": "markdown",
"id": "0a763f8b",
"id": "3d98f5f4",
"metadata": {},
"source": [
"Zum Umwandeln in einen 'richtigen' Vektor dient die Funktion `collect()`.\n"
@ -256,7 +256,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "0e0be9dd",
"id": "fe033c47",
"metadata": {},
"outputs": [],
"source": [
@ -265,7 +265,7 @@
},
{
"cell_type": "markdown",
"id": "568f2f9f",
"id": "a94e5258",
"metadata": {},
"source": [
"Recht nützlich, z.B. beim Vorbereiten von Daten zum Plotten, ist der *range*-Typ `LinRange`.\n"
@ -274,7 +274,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "8596862b",
"id": "e4b40085",
"metadata": {},
"outputs": [],
"source": [
@ -283,19 +283,471 @@
},
{
"cell_type": "markdown",
"id": "f148954b",
"id": "bde8b38f",
"metadata": {},
"source": [
"`LinRange(start, stop, n)` erzeugt eine äquidistante Liste von `n` Werten von denen der erste und der letzte die vorgegebenen Grenzen sind. \n",
"Mit `collect()` kann man bei Bedarf auch daraus den entsprechenden Vektor gewinnen.\n"
"Mit `collect()` kann man bei Bedarf auch daraus den entsprechenden Vektor gewinnen.\n",
"\n",
"\n",
"## Dictionaries \n",
"\n",
"- _Dictionaries_ (deutsch: \"assoziative Liste\" oder \"Zuordnungstabelle\" oder ...) sind spezielle Container. \n",
"- Einträge in einem Vektor `v` sind durch einen Index 1,2,3.... addressierbar: `v[i]`\n",
"- Einträge in einem _dictionary_ sind durch allgemeinere _keys_ addressierbar. \n",
"- Ein _dictionary_ ist eine Ansammlung von _key-value_-Paaren.\n",
"- Damit haben _dictionaries_ in Julia den parametrisierten Typ `Dict{S,T}`, wobei `S` der Typ der _keys_ und `T` der Typ der _values_ ist\n",
"\n",
"\n",
"Man kann sie explizit anlegen:\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "25c7aefc",
"metadata": {},
"outputs": [],
"source": [
"# Einwohner 2020 in Millionen, Quelle: wikipedia\n",
"\n",
"EW = Dict(\"Berlin\" => 3.66, \"Hamburg\" => 1.85, \n",
" \"München\" => 1.49, \"Köln\" => 1.08)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "9620f365",
"metadata": {},
"outputs": [],
"source": [
"typeof(EW)"
]
},
{
"cell_type": "markdown",
"id": "d3b4d2af",
"metadata": {},
"source": [
"und mit den _keys_ indizieren:\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "62938a1b",
"metadata": {},
"outputs": [],
"source": [
"EW[\"Berlin\"]"
]
},
{
"cell_type": "markdown",
"id": "73ddf61d",
"metadata": {},
"source": [
"Das Abfragen eines nicht existierenden _keys_ ist natürlich ein Fehler.\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "6e16eb41",
"metadata": {},
"outputs": [],
"source": [
"EW[\"Leipzig\"]"
]
},
{
"cell_type": "markdown",
"id": "49a6d001",
"metadata": {},
"source": [
"Man kann ja auch vorher mal anfragen...\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "e43aec5d",
"metadata": {},
"outputs": [],
"source": [
"haskey(EW, \"Leipzig\")"
]
},
{
"cell_type": "markdown",
"id": "a1cefaa1",
"metadata": {},
"source": [
"... oder die Funktion `get(dict, key, default)` benutzen, die bei nicht existierendem Key keinen Fehler wirft sondern das 3. Argument zurückgibt. \n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "e31c792c",
"metadata": {},
"outputs": [],
"source": [
"@show get(EW, \"Leipzig\", -1) get(EW, \"Berlin\", -1);"
]
},
{
"cell_type": "markdown",
"id": "f625eaaa",
"metadata": {},
"source": [
"Man kann sich auch alle `keys` und `values` als spezielle Container geben lassen.\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "21460e3a",
"metadata": {},
"outputs": [],
"source": [
"keys(EW)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "a87d9788",
"metadata": {},
"outputs": [],
"source": [
"values(EW)"
]
},
{
"cell_type": "markdown",
"id": "97b96369",
"metadata": {},
"source": [
"Man kann über die `keys` iterieren...\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "41e9189f",
"metadata": {},
"outputs": [],
"source": [
"for i in keys(EW)\n",
" n = EW[i]\n",
" println(\"Die Stadt $i hat $n Millionen Einwohner.\")\n",
"end"
]
},
{
"cell_type": "markdown",
"id": "b2fe653a",
"metadata": {},
"source": [
"odere gleich über `key-value`-Paare.\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "0b445207",
"metadata": {},
"outputs": [],
"source": [
"for (stadt, ew) ∈ EW\n",
" println(\"$stadt : $ew Mill.\")\n",
"end"
]
},
{
"cell_type": "markdown",
"id": "6fcd4019",
"metadata": {},
"source": [
"### Erweitern und Modifizieren\n",
"\n",
"Man kann in ein `Dict` zusätzliche `key-value`-Paare eintragen...\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "94c4f076",
"metadata": {},
"outputs": [],
"source": [
"EW[\"Leipzig\"] = 0.52\n",
"EW[\"Dresden\"] = 0.52 \n",
"EW"
]
},
{
"cell_type": "markdown",
"id": "ed90d684",
"metadata": {},
"source": [
"und einen `value` ändern.\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "c57e8dd2",
"metadata": {},
"outputs": [],
"source": [
"# Oh, das war bei Leipzig die Zahl von 2010, nicht 2020\n",
"\n",
"EW[\"Leipzig\"] = 0.597\n",
"EW"
]
},
{
"cell_type": "markdown",
"id": "3d0eadd7",
"metadata": {},
"source": [
"Ein Paar kann über seinen `key` auch gelöscht werden.\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "0dfd9f2d",
"metadata": {},
"outputs": [],
"source": [
"delete!(EW, \"Dresden\")"
]
},
{
"cell_type": "markdown",
"id": "3db2aa1f",
"metadata": {},
"source": [
"Zahlreiche Funktionen können mit `Dicts` wie mit anderen Containern arbeiten.\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "1204aaab",
"metadata": {},
"outputs": [],
"source": [
"maximum(values(EW))"
]
},
{
"cell_type": "markdown",
"id": "6a4946b4",
"metadata": {},
"source": [
"### Anlegen eines leeren Dictionaries\n",
"\n",
"Ohne Typspezifikation ...\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "1f82ac79",
"metadata": {},
"outputs": [],
"source": [
"d1 = Dict()"
]
},
{
"cell_type": "markdown",
"id": "27c98eaf",
"metadata": {},
"source": [
"und mit Typspezifikation:\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "1b8f201e",
"metadata": {},
"outputs": [],
"source": [
"d2 = Dict{String, Int}()"
]
},
{
"cell_type": "markdown",
"id": "7fe71a3b",
"metadata": {},
"source": [
"### Umwandlung in Vektoren: `collect()`\n",
"\n",
"- `keys(dict)` und `values(dict)` sind spezielle Datentypen. \n",
"- Die Funktion `collect()` macht daraus eine Liste vom Typ `Vector`. \n",
"- `collect(dict)` liefert eine Liste vom Typ `Vector{Pair{S,T}}` \n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "2dc85bdd",
"metadata": {},
"outputs": [],
"source": [
"collect(EW)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "100dbbf1",
"metadata": {},
"outputs": [],
"source": [
"collect(keys(EW)), collect(values(EW))"
]
},
{
"cell_type": "markdown",
"id": "f9703f73",
"metadata": {},
"source": [
"### Geordnetes Iterieren über ein Dictionary\n",
"\n",
"Wir sortieren die Keys. Als Strings werden sie alphabetisch sortiert. Mit dem `rev`-Parameter wird rückwärts sortiert.\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "3c02f0ca",
"metadata": {},
"outputs": [],
"source": [
"for k in sort(collect(keys(EW)), rev = true)\n",
" n = EW[k]\n",
" println(\"$k hat $n Millionen Einw. \")\n",
"end"
]
},
{
"cell_type": "markdown",
"id": "c20f0654",
"metadata": {},
"source": [
"Wir sortieren `collect(dict)`. Das ist ein Vektor von Paaren. Mit `by` definieren wir, wonach zu sortieren ist: nach dem 2. Element des Paares. \n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "89ee04e9",
"metadata": {},
"outputs": [],
"source": [
"for (k,v) in sort(collect(EW), by = pair -> last(pair), rev=false)\n",
" println(\"$k hat $v Mill. EW\")\n",
"end"
]
},
{
"cell_type": "markdown",
"id": "94ba9752",
"metadata": {},
"source": [
"### Eine Anwendung von Dictionaries: Zählen von Häufigkeiten\n",
"\n",
"Wir machen 'experimentelle Stochastik' mit 2 Würfeln: \n",
"\n",
"Gegeben sei `l`, eine Liste mit den Ergebnissen von 100 000 Pasch-Würfen, also 100 000 Zahlen zwischen 2 und 12.\n",
"\n",
"Wie häufig sind die Zahlen 2 bis 12?\n",
"\n",
"\n",
"Wir (lassen) würfeln:\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "a7ff829d",
"metadata": {},
"outputs": [],
"source": [
"l = rand(1:6, 100_000) .+ rand(1:6, 100_000)"
]
},
{
"cell_type": "markdown",
"id": "48a58503",
"metadata": {},
"source": [
"Wir zählen mit Hilfe eines Dictionaries die Häufigkeiten der Ereignisse. Dazu nehmen wir das Ereignis als `key` und seine Häufigkeit als `value`.\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "dd2bcd79",
"metadata": {},
"outputs": [],
"source": [
"# In diesem Fall könnte man das auch mit einem einfachen Vektor\n",
"# lösen. Eine bessere Illustration wäre z.B. Worthäufigkeit in\n",
"# einem Text. Dann ist i keine ganze Zahl sondern ein Wort=String\n",
"\n",
"d = Dict{Int,Int}() # das Dict zum 'reinzählen'\n",
"\n",
"for i in l # für jedes i wird d[i] erhöht. \n",
" d[i] = get(d, i, 0) + 1 \n",
"end\n",
"d"
]
},
{
"cell_type": "markdown",
"id": "62fe53b9",
"metadata": {},
"source": [
"Das Ergebnis:\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "154252d3",
"metadata": {},
"outputs": [],
"source": [
"using Plots\n",
"\n",
"plot(collect(keys(d)), collect(values(d)), seriestype=:scatter)"
]
},
{
"cell_type": "markdown",
"id": "dd482553",
"metadata": {},
"source": [
"##### Das Erklär-Bild dazu:\n",
"\n",
"[https://math.stackexchange.com/questions/1204396/why-is-the-sum-of-the-rolls-of-two-dices-a-binomial-distribution-what-is-define](https://math.stackexchange.com/questions/1204396/why-is-the-sum-of-the-rolls-of-two-dices-a-binomial-distribution-what-is-define)\n"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Julia 1.8.5",
"display_name": "Julia 1.10.2",
"language": "julia",
"name": "julia-1.8"
"name": "julia-1.10"
}
},
"nbformat": 4,

File diff suppressed because it is too large Load Diff

View File

@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "markdown",
"id": "87512b9c",
"id": "c68c2670",
"metadata": {},
"source": [
"# Funktionen und Operatoren\n",
@ -19,7 +19,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "2cdf33d6",
"id": "9443ccb7",
"metadata": {},
"outputs": [],
"source": [
@ -30,7 +30,7 @@
},
{
"cell_type": "markdown",
"id": "d22901e3",
"id": "50291f2a",
"metadata": {},
"source": [
"II. Als \"Einzeiler\" \n"
@ -39,7 +39,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "338f000a",
"id": "4657e421",
"metadata": {},
"outputs": [],
"source": [
@ -48,7 +48,7 @@
},
{
"cell_type": "markdown",
"id": "f14a745f",
"id": "d36c44e2",
"metadata": {},
"source": [
"III. Als anonyme Funktionen\n"
@ -57,7 +57,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "44319487",
"id": "02e66f6e",
"metadata": {},
"outputs": [],
"source": [
@ -66,7 +66,7 @@
},
{
"cell_type": "markdown",
"id": "d8f8978c",
"id": "f3c09c53",
"metadata": {},
"source": [
"### Block-Form und `return`\n",
@ -106,7 +106,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "721d72e8",
"id": "6694b46d",
"metadata": {},
"outputs": [],
"source": [
@ -121,7 +121,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "f6847d6a",
"id": "ee012edc",
"metadata": {},
"outputs": [],
"source": [
@ -131,7 +131,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "483d2b6b",
"id": "fca80289",
"metadata": {},
"outputs": [],
"source": [
@ -140,7 +140,7 @@
},
{
"cell_type": "markdown",
"id": "66a0d115",
"id": "39cf5d56",
"metadata": {},
"source": [
"### Einzeiler-Form\n",
@ -186,7 +186,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "e07295eb",
"id": "35a8bd70",
"metadata": {},
"outputs": [],
"source": [
@ -196,7 +196,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "b8ca9baf",
"id": "f8cec9b2",
"metadata": {},
"outputs": [],
"source": [
@ -205,7 +205,7 @@
},
{
"cell_type": "markdown",
"id": "9ba0e8db",
"id": "71388002",
"metadata": {},
"source": [
"Ein weiteres Beispiel ist `filter(test, collection)`, wobei ein Test eine Funktion ist, die ein `Bool` zurückgibt.\n"
@ -214,7 +214,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "12731194",
"id": "11d55610",
"metadata": {},
"outputs": [],
"source": [
@ -223,7 +223,7 @@
},
{
"cell_type": "markdown",
"id": "f4af9755",
"id": "36b2a20b",
"metadata": {},
"source": [
"## Argumentübergabe\n",
@ -237,7 +237,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "d34f0256",
"id": "650adea1",
"metadata": {},
"outputs": [],
"source": [
@ -251,7 +251,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "f83f5e37",
"id": "49a771b3",
"metadata": {},
"outputs": [],
"source": [
@ -267,7 +267,7 @@
},
{
"cell_type": "markdown",
"id": "7476eab9",
"id": "d0d2e303",
"metadata": {},
"source": [
"## Varianten von Funktionsargumenten\n",
@ -285,7 +285,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "e67e1006",
"id": "5ec6f56a",
"metadata": {},
"outputs": [],
"source": [
@ -298,7 +298,7 @@
},
{
"cell_type": "markdown",
"id": "1d889283",
"id": "4389ea71",
"metadata": {},
"source": [
"Eine Funktion nur mit _keyword_-Argumenten wird so deklariert:\n"
@ -307,7 +307,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "e79269ee",
"id": "0fc2aeac",
"metadata": {},
"outputs": [],
"source": [
@ -318,7 +318,7 @@
},
{
"cell_type": "markdown",
"id": "14d197af",
"id": "26e02ff2",
"metadata": {},
"source": [
"## Funktionen sind ganz normale Objekte\n",
@ -329,7 +329,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "2e0a4b89",
"id": "17b38616",
"metadata": {},
"outputs": [],
"source": [
@ -339,7 +339,7 @@
},
{
"cell_type": "markdown",
"id": "6f0fef37",
"id": "325c567b",
"metadata": {},
"source": [
"- Sie können als Argumente an Funktionen übergeben werden.\n"
@ -348,7 +348,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "c6db6121",
"id": "4d5be6cf",
"metadata": {},
"outputs": [],
"source": [
@ -369,7 +369,7 @@
},
{
"cell_type": "markdown",
"id": "b8eb1978",
"id": "43f02a36",
"metadata": {},
"source": [
"- Sie können von Funktionen erzeugt und als Ergebnis `return`t werden.\n"
@ -378,7 +378,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "67e640ce",
"id": "81e0ad89",
"metadata": {},
"outputs": [],
"source": [
@ -393,7 +393,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "a78dd669",
"id": "5491730c",
"metadata": {},
"outputs": [],
"source": [
@ -403,7 +403,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "23b557af",
"id": "f39aa8b1",
"metadata": {},
"outputs": [],
"source": [
@ -413,7 +413,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "440b7568",
"id": "4b708a03",
"metadata": {},
"outputs": [],
"source": [
@ -422,7 +422,7 @@
},
{
"cell_type": "markdown",
"id": "ab655f0f",
"id": "5c0d6771",
"metadata": {},
"source": [
"Die obige Funktion `generate_add_func()` lässt sich auch kürzer definieren. Der innere Funktionsname `addx()` ist sowieso lokal und außerhalb nicht verfügbar. Also kann man eine anonyme Funktion verwenden.\n"
@ -431,7 +431,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "d0b76e9c",
"id": "7817f2ff",
"metadata": {},
"outputs": [],
"source": [
@ -440,7 +440,7 @@
},
{
"cell_type": "markdown",
"id": "9dcb1129",
"id": "0cf5d3c0",
"metadata": {},
"source": [
"## Zusammensetzung von Funktionen: die Operatoren $\\circ$ und `|>`\n",
@ -453,7 +453,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "fcaf335f",
"id": "cae2ce88",
"metadata": {},
"outputs": [],
"source": [
@ -463,7 +463,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "48dd034e",
"id": "a16fb3c6",
"metadata": {},
"outputs": [],
"source": [
@ -474,7 +474,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "2ecd0bb3",
"id": "ed8ec445",
"metadata": {},
"outputs": [],
"source": [
@ -483,7 +483,7 @@
},
{
"cell_type": "markdown",
"id": "64c2f8ca",
"id": "6c6d5a5a",
"metadata": {},
"source": [
"- Es gibt auch einen Operator, mit dem Funktionen \"von rechts\" wirken und zusammengesetzt werden können _(piping)_\n"
@ -492,7 +492,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "8cdef694",
"id": "d32aaa8f",
"metadata": {},
"outputs": [],
"source": [
@ -502,7 +502,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "4fd01026",
"id": "c5b9236a",
"metadata": {},
"outputs": [],
"source": [
@ -511,7 +511,7 @@
},
{
"cell_type": "markdown",
"id": "d8c6e6f3",
"id": "2af53243",
"metadata": {},
"source": [
"- Natürlich kann man auch diese Operatoren 'broadcasten' (s. @sec-broadcast). Hier wirkt ein Vektor von Funktionen elementweise auf einen Vektor von Argumenten:\n"
@ -520,7 +520,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "94691aad",
"id": "4ea2ad9f",
"metadata": {},
"outputs": [],
"source": [
@ -529,7 +529,7 @@
},
{
"cell_type": "markdown",
"id": "f4b75c54",
"id": "f941ceb5",
"metadata": {},
"source": [
"## Die `do`-Notation\n",
@ -552,7 +552,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "76c02df9",
"id": "a6620e38",
"metadata": {},
"outputs": [],
"source": [
@ -563,7 +563,7 @@
},
{
"cell_type": "markdown",
"id": "a708ad3e",
"id": "26486b16",
"metadata": {},
"source": [
"Der Sinn besteht natürlich in der Anwendung mit komplexeren Funktionen, wie diesem aus zwei Teilstücken zusammengesetzten Integranden:\n"
@ -572,7 +572,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "e3012c9b",
"id": "53714315",
"metadata": {},
"outputs": [],
"source": [
@ -589,7 +589,7 @@
},
{
"cell_type": "markdown",
"id": "c38a800c",
"id": "c973f2c1",
"metadata": {},
"source": [
"## Funktionsartige Objekte\n",
@ -600,7 +600,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "5de4f59a",
"id": "73cc94fd",
"metadata": {},
"outputs": [],
"source": [
@ -617,7 +617,7 @@
},
{
"cell_type": "markdown",
"id": "8b0b62a3",
"id": "99427b65",
"metadata": {},
"source": [
"Die folgende Methode macht diese Struktur `callable`.\n"
@ -626,7 +626,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "0a5cb287",
"id": "94bbfd15",
"metadata": {},
"outputs": [],
"source": [
@ -637,7 +637,7 @@
},
{
"cell_type": "markdown",
"id": "a5149012",
"id": "b13ba4a8",
"metadata": {},
"source": [
"Jetzt kann man die Objekte, wenn gewünscht, auch wie Funktionen verwenden.\n"
@ -646,7 +646,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "b271dbf1",
"id": "9b490828",
"metadata": {},
"outputs": [],
"source": [
@ -655,7 +655,7 @@
},
{
"cell_type": "markdown",
"id": "b355c1b0",
"id": "bff0bff7",
"metadata": {},
"source": [
"## Operatoren und spezielle Formen\n",
@ -666,7 +666,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "4f71f917",
"id": "da10ff9f",
"metadata": {},
"outputs": [],
"source": [
@ -676,7 +676,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "b19e79cf",
"id": "177a174d",
"metadata": {},
"outputs": [],
"source": [
@ -686,7 +686,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "869917d4",
"id": "f0f52152",
"metadata": {},
"outputs": [],
"source": [
@ -695,7 +695,7 @@
},
{
"cell_type": "markdown",
"id": "490bceac",
"id": "39178d6d",
"metadata": {},
"source": [
"- Auch Konstruktionen wie `x[i]`, `a.x`, `[x; y]` werden vom Parser zu Funktionsaufrufen umgewandelt.\n",
@ -755,7 +755,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "4d92cc97",
"id": "419bcd07",
"metadata": {},
"outputs": [],
"source": [
@ -764,7 +764,7 @@
},
{
"cell_type": "markdown",
"id": "ec6b89f6",
"id": "3b37d178",
"metadata": {},
"source": [
"werden vom Parser in eine Baumstruktur überführt.\n"
@ -773,7 +773,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "9f607850",
"id": "7e5bd52c",
"metadata": {},
"outputs": [],
"source": [
@ -784,7 +784,7 @@
},
{
"cell_type": "markdown",
"id": "68328dda",
"id": "d26e9cbc",
"metadata": {},
"source": [
"- Die Auswertung solcher Ausdrücke wird durch \n",
@ -802,7 +802,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "71fdbe34",
"id": "3faed089",
"metadata": {},
"outputs": [],
"source": [
@ -812,7 +812,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "fc26727a",
"id": "559f6beb",
"metadata": {},
"outputs": [],
"source": [
@ -821,7 +821,7 @@
},
{
"cell_type": "markdown",
"id": "0253c57a",
"id": "115f7493",
"metadata": {},
"source": [
"Zuweisungen wie `=`, `+=`, `*=`,... sind gleichrangig und rechtsassoziativ.\n"
@ -830,7 +830,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "7f9891ea",
"id": "72456757",
"metadata": {},
"outputs": [],
"source": [
@ -846,16 +846,16 @@
},
{
"cell_type": "markdown",
"id": "9eeccc4c",
"id": "a716bc08",
"metadata": {},
"source": [
"Natürlich kann man die Assoziativität in Julia auch abfragen. Die entsprechenden Funktionen werden nicht expizit aus dem `Base`-Modul exportiert, deshalb muss man den Modulnamen beim Aufruf angeben. \n"
"Natürlich kann man die Assoziativität in Julia auch abfragen. Die entsprechenden Funktionen werden nicht explizit aus dem `Base`-Modul exportiert, deshalb muss man den Modulnamen beim Aufruf angeben. \n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "23fe3c28",
"id": "f2317e6a",
"metadata": {},
"outputs": [],
"source": [
@ -867,7 +867,7 @@
},
{
"cell_type": "markdown",
"id": "148b459a",
"id": "3a7e3a79",
"metadata": {},
"source": [
"Also ist der Potenzoperator rechtsassoziativ.\n"
@ -876,7 +876,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "d1ad2685",
"id": "21fe9789",
"metadata": {},
"outputs": [],
"source": [
@ -885,7 +885,7 @@
},
{
"cell_type": "markdown",
"id": "86c59c17",
"id": "0d333e68",
"metadata": {},
"source": [
"### Vorrang\n",
@ -896,7 +896,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "9c97eee7",
"id": "e5ad39a5",
"metadata": {},
"outputs": [],
"source": [
@ -908,7 +908,7 @@
},
{
"cell_type": "markdown",
"id": "177ecf6d",
"id": "4decdf33",
"metadata": {},
"source": [
"- 11 ist kleiner als 12, also geht 'Punktrechnung vor Strichrechnung'\n",
@ -919,7 +919,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "30c88bf2",
"id": "9450f974",
"metadata": {},
"outputs": [],
"source": [
@ -932,7 +932,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "b4a0a3ee",
"id": "d631e121",
"metadata": {},
"outputs": [],
"source": [
@ -942,7 +942,7 @@
},
{
"cell_type": "markdown",
"id": "0384575c",
"id": "0969d330",
"metadata": {},
"source": [
"Nochmal zum Beispiel vom Anfang von @sec-vorrang:\n"
@ -951,7 +951,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "56488075",
"id": "107124d7",
"metadata": {},
"outputs": [],
"source": [
@ -961,7 +961,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "543e7874",
"id": "420964a2",
"metadata": {},
"outputs": [],
"source": [
@ -973,7 +973,7 @@
},
{
"cell_type": "markdown",
"id": "bcb7fc77",
"id": "9c17c3e7",
"metadata": {},
"source": [
"Nach diesen Vorrangregeln wird der Beispielausdruck also wie folgt ausgewertet:\n"
@ -982,7 +982,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "89af1388",
"id": "43b21b33",
"metadata": {},
"outputs": [],
"source": [
@ -991,7 +991,7 @@
},
{
"cell_type": "markdown",
"id": "509a3955",
"id": "2d52102a",
"metadata": {},
"source": [
"(Das entspricht natürlich dem oben gezeigten *parse-tree*)\n",
@ -1021,7 +1021,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "c134b798",
"id": "a4465163",
"metadata": {},
"outputs": [],
"source": [
@ -1030,7 +1030,7 @@
},
{
"cell_type": "markdown",
"id": "aafaa2d1",
"id": "1529af73",
"metadata": {},
"source": [
"::: \n",
@ -1045,7 +1045,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "61fc5df5",
"id": "8dbccf82",
"metadata": {},
"outputs": [],
"source": [
@ -1055,7 +1055,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "8c609c3b",
"id": "26415d53",
"metadata": {},
"outputs": [],
"source": [
@ -1066,7 +1066,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "44a6345d",
"id": "b07aabae",
"metadata": {},
"outputs": [],
"source": [
@ -1076,7 +1076,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "660dfb1f",
"id": "09f3ecc4",
"metadata": {},
"outputs": [],
"source": [
@ -1085,7 +1085,7 @@
},
{
"cell_type": "markdown",
"id": "0fecdb42",
"id": "d1e4bc70",
"metadata": {},
"source": [
"- Funktionsanwendung `f(...)` hat Vorrang vor allen Operatoren\n"
@ -1094,7 +1094,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "198bb0f8",
"id": "a9c32959",
"metadata": {},
"outputs": [],
"source": [
@ -1103,7 +1103,7 @@
},
{
"cell_type": "markdown",
"id": "f153e028",
"id": "e9915990",
"metadata": {},
"source": [
"### Zusätzliche Operatoren\n",
@ -1126,15 +1126,9 @@
],
"metadata": {
"kernelspec": {
"display_name": "Julia 1.8.5",
"display_name": "Julia 1.10.2",
"language": "julia",
"name": "julia-1.8"
},
"language_info": {
"file_extension": ".jl",
"mimetype": "application/julia",
"name": "julia",
"version": "1.8.5"
"name": "julia-1.10"
}
},
"nbformat": 4,

View File

@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "markdown",
"id": "9bb241ad",
"id": "f21dc71b",
"metadata": {},
"source": [
"# Erste Miniprogramme\n",
@ -72,7 +72,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "b5ec6b90",
"id": "44d0f59e",
"metadata": {},
"outputs": [],
"source": [
@ -87,7 +87,7 @@
},
{
"cell_type": "markdown",
"id": "e4de7d69",
"id": "4d9f5b4f",
"metadata": {},
"source": [
":::\n",
@ -102,7 +102,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "772bbe68",
"id": "9d36a90d",
"metadata": {},
"outputs": [],
"source": [
@ -111,7 +111,7 @@
},
{
"cell_type": "markdown",
"id": "b9b95d73",
"id": "71a52de7",
"metadata": {},
"source": [
":::\n",
@ -151,7 +151,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "c0730a2a",
"id": "15983324",
"metadata": {},
"outputs": [],
"source": [
@ -170,7 +170,7 @@
},
{
"cell_type": "markdown",
"id": "1caa208b",
"id": "7cafe59e",
"metadata": {},
"source": [
":::\n",
@ -180,7 +180,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "72341556",
"id": "82139e32",
"metadata": {},
"outputs": [],
"source": [
@ -192,7 +192,7 @@
},
{
"cell_type": "markdown",
"id": "5eeb2626",
"id": "1467ade0",
"metadata": {},
"source": [
"Im Sinne der Aufgabe wenden wir die Funktion wiederholt an:\n"
@ -201,7 +201,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "da47c136",
"id": "2a91c9da",
"metadata": {},
"outputs": [],
"source": [
@ -214,7 +214,7 @@
},
{
"cell_type": "markdown",
"id": "e67b1670",
"id": "1399219b",
"metadata": {},
"source": [
"... und haben hier einen der '89er Zyklen' getroffen.\n",
@ -232,7 +232,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "3868d34e",
"id": "8b76324d",
"metadata": {},
"outputs": [],
"source": [
@ -248,7 +248,7 @@
},
{
"cell_type": "markdown",
"id": "10ce44d1",
"id": "06d73770",
"metadata": {},
"source": [
":::\n",
@ -259,7 +259,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "54521e6a",
"id": "7a0051f2",
"metadata": {},
"outputs": [],
"source": [
@ -274,7 +274,7 @@
},
{
"cell_type": "markdown",
"id": "4a545b8c",
"id": "000b5826",
"metadata": {},
"source": [
"Zahlen, bei denen die iterierte Quadratquersummenbildung bei 1 endet, heißen übrigens [fröhliche Zahlen](https://de.wikipedia.org/wiki/Fr%C3%B6hliche_Zahl) und wir haben gerade die Anzahl der traurigen Zahlen kleiner als 10.000.000 berechnet.\n",
@ -288,7 +288,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "a7253bc1",
"id": "db3ef4ef",
"metadata": {},
"outputs": [],
"source": [
@ -322,7 +322,7 @@
},
{
"cell_type": "markdown",
"id": "772bec11",
"id": "8d2084be",
"metadata": {},
"source": [
":::"
@ -331,9 +331,9 @@
],
"metadata": {
"kernelspec": {
"display_name": "Julia 1.8.5",
"display_name": "Julia 1.10.2",
"language": "julia",
"name": "julia-1.8"
"name": "julia-1.10"
}
},
"nbformat": 4,

View File

@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "raw",
"id": "9d63401b",
"id": "9e1ef849",
"metadata": {},
"source": [
"---\n",
@ -18,7 +18,7 @@
},
{
"cell_type": "markdown",
"id": "405d242e",
"id": "beff12c8",
"metadata": {},
"source": [
"# Ein Beispiel zur Stabilität von Gleitkommaarithmetik\n",
@ -29,7 +29,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "f17a5fcb",
"id": "a7810264",
"metadata": {},
"outputs": [],
"source": [
@ -84,7 +84,7 @@
},
{
"cell_type": "markdown",
"id": "7745166c",
"id": "8d4bd1ab",
"metadata": {},
"source": [
"Eine untere Schranke für $2\\pi$, den Umfang des Einheitskreises, erhält man durch die\n",
@ -151,7 +151,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "d83237c5",
"id": "3f238690",
"metadata": {},
"outputs": [],
"source": [
@ -186,7 +186,7 @@
},
{
"cell_type": "markdown",
"id": "dcdecd41",
"id": "0c0178f5",
"metadata": {},
"source": [
"Während Iteration B sich stabilisiert bei einem innerhalb der Maschinengenauigkeit korrekten Wert für π, wird Iteration A schnell instabil. Ein Plot der relativen Fehler $\\epsilon_i$ bestätigt das:\n"
@ -195,7 +195,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "4404adb1",
"id": "f415aab0",
"metadata": {},
"outputs": [],
"source": [
@ -212,7 +212,7 @@
},
{
"cell_type": "markdown",
"id": "ac5d56d5",
"id": "02116ab2",
"metadata": {},
"source": [
"## Stabilität und Auslöschung\n",
@ -223,7 +223,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "e807fa2b",
"id": "3d50cba2",
"metadata": {},
"outputs": [],
"source": [
@ -232,7 +232,7 @@
},
{
"cell_type": "markdown",
"id": "68979310",
"id": "5ba088ba",
"metadata": {},
"source": [
"Weitere Iterationen verbessern das Ergebnis nicht mehr. Sie stabilisieren sich bei einem relativen Fehler von etwa 2.5 Maschinenepsilon:\n"
@ -241,7 +241,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "6a9f7b29",
"id": "2bcae61d",
"metadata": {},
"outputs": [],
"source": [
@ -250,7 +250,7 @@
},
{
"cell_type": "markdown",
"id": "09be0e03",
"id": "0bfd8235",
"metadata": {},
"source": [
"Die Form Iteration A ist instabil. Bereits bei $i=16$ beginnt der relative Fehler wieder zu wachsen.\n",
@ -262,7 +262,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "2ccb85ad",
"id": "365d4c27",
"metadata": {},
"outputs": [],
"source": [
@ -283,7 +283,7 @@
},
{
"cell_type": "markdown",
"id": "27616d4d",
"id": "04736a02",
"metadata": {},
"source": [
"Man sieht die Abnahme der Zahl der signifikanten Ziffern. Man sieht auch, dass eine Verwendung von `BigFloat` mit einer Mantissenlänge von hier 80 Bit das Einsetzen des Auslöschungseffekts nur etwas hinaussschieben kann. \n",
@ -303,9 +303,9 @@
],
"metadata": {
"kernelspec": {
"display_name": "Julia 1.8.5",
"display_name": "Julia 1.10.2",
"language": "julia",
"name": "julia-1.8"
"name": "julia-1.10"
}
},
"nbformat": 4,

View File

@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "markdown",
"id": "e009ef80",
"id": "65cc0031",
"metadata": {},
"source": [
"# First Contact\n",
@ -16,7 +16,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "b488cb23",
"id": "f9151e6d",
"metadata": {},
"outputs": [],
"source": [
@ -45,7 +45,7 @@
},
{
"cell_type": "markdown",
"id": "76000398",
"id": "3c611742",
"metadata": {},
"source": [
"Berechne $\\qquad 12^{1/3} + \\frac{3\\sqrt{2}}{\\sin(0.5)-\\cos(\\frac{\\pi}{4})\\log(3)}+ e^5$\n"
@ -54,7 +54,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "0f9feb86",
"id": "fd02456e",
"metadata": {},
"outputs": [],
"source": [
@ -63,7 +63,7 @@
},
{
"cell_type": "markdown",
"id": "3e9fad84",
"id": "9ce12c0f",
"metadata": {},
"source": [
"Man beachte:\n",
@ -74,7 +74,7 @@
"- Das Multiplikationszeichen `a*b` kann nach einer Zahl weggelassen werden, wenn eine Variable, Funktion oder Klammer folgt.\n",
"\n",
"\n",
"## Die wichtigsten Tasten: `Tab` und `?`\n",
"## Die wichtigsten Tasten: `Tab` und `?` {#sec-tab}\n",
"\n",
"Man drücke beim Programmieren immer wieder die Tabulatortaste, sobald 2...3 Buchstaben eines Wortes getippt sind. Es werden dann mögliche Ergänzungen angezeigt bzw. ergänzt, wenn die Ergänzung eindeutig ist. Das spart Zeit und bildet ungemein:\n"
]
@ -82,7 +82,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "734300ba",
"id": "e2ca6f27",
"metadata": {},
"outputs": [],
"source": [
@ -93,7 +93,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "155bc575",
"id": "9fdfabe6",
"metadata": {},
"outputs": [],
"source": [
@ -103,7 +103,7 @@
},
{
"cell_type": "markdown",
"id": "ba74dc32",
"id": "d8ecd73b",
"metadata": {},
"source": [
"Die eingebaute Julia-Hilfe `?name` zu allen Funktionen und Konstrukten ist sehr umfassend. Hier ein eher kurzes Beispiel: \n"
@ -112,7 +112,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "1b941a97",
"id": "9ba34e9d",
"metadata": {},
"outputs": [],
"source": [
@ -121,7 +121,7 @@
},
{
"cell_type": "markdown",
"id": "c8f7da7b",
"id": "c798d174",
"metadata": {},
"source": [
":::{.content-hidden unless-format=\"xxx\"}\n",
@ -160,7 +160,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "da1dc7ec",
"id": "2f60e4e5",
"metadata": {},
"outputs": [],
"source": [
@ -170,7 +170,7 @@
},
{
"cell_type": "markdown",
"id": "37b29541",
"id": "20819c0a",
"metadata": {},
"source": [
"Im interaktiven Betrieb zeigt Julia das Ergebnis der letzten Operation an.\n",
@ -201,7 +201,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "173f7324",
"id": "2874204c",
"metadata": {},
"outputs": [],
"source": [
@ -214,7 +214,7 @@
},
{
"cell_type": "markdown",
"id": "13a8984f",
"id": "d5343251",
"metadata": {},
"source": [
"Die Standard-Gleitkommazahl hat eine Länge von 64 Bit, entspricht also einer `double` in C/C++/Java.\n",
@ -227,7 +227,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "cd3b3e96",
"id": "544f8fe6",
"metadata": {},
"outputs": [],
"source": [
@ -242,7 +242,7 @@
},
{
"cell_type": "markdown",
"id": "eae463bf",
"id": "b1734df1",
"metadata": {},
"source": [
"## Druckanweisungen\n",
@ -252,7 +252,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "df98312b",
"id": "b44d0f53",
"metadata": {},
"outputs": [],
"source": [
@ -266,7 +266,7 @@
},
{
"cell_type": "markdown",
"id": "b74dcb3f",
"id": "3baa2a89",
"metadata": {},
"source": [
"Beide Funkionen können als Argument eine Liste von *strings* und Variablen bekommen. Man kann Variablen auch in *strings* einbetten, indem man dem Variablennamen ein Dollarzeichen voranstellt *(string interpolation)*.\n"
@ -275,7 +275,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "3b76d855",
"id": "fa3b2601",
"metadata": {},
"outputs": [],
"source": [
@ -288,7 +288,7 @@
},
{
"cell_type": "markdown",
"id": "c06fc5da",
"id": "fe3b44d2",
"metadata": {},
"source": [
":::{.callout-note .titlenormal collapse=true icon=false }\n",
@ -300,7 +300,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "00a46544",
"id": "198c1231",
"metadata": {},
"outputs": [],
"source": [
@ -309,7 +309,7 @@
},
{
"cell_type": "markdown",
"id": "3ba46a2c",
"id": "847182e6",
"metadata": {},
"source": [
":::\n",
@ -321,7 +321,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "6e83b8e2",
"id": "8c4c8af3",
"metadata": {},
"outputs": [],
"source": [
@ -334,7 +334,7 @@
},
{
"cell_type": "markdown",
"id": "6ae72d3a",
"id": "270a968d",
"metadata": {},
"source": [
"Nach ihrer Definition kann die Funktion benutzt (aufgerufen) werden. Die in der Definition verwendeten Variablen `a,b,c,c2` sind lokale Variablen und stehen außerhalb der Funktionsdefinition nicht zur Verfügung. \n"
@ -343,7 +343,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "2b68ec32",
"id": "aeb1b763",
"metadata": {},
"outputs": [],
"source": [
@ -356,7 +356,7 @@
},
{
"cell_type": "markdown",
"id": "d62b25c3",
"id": "83623a5d",
"metadata": {},
"source": [
"Sehr einfache Funktionen können auch als Einzeiler definiert werden.\n"
@ -365,7 +365,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "436bf54a",
"id": "bb93d920",
"metadata": {},
"outputs": [],
"source": [
@ -374,7 +374,7 @@
},
{
"cell_type": "markdown",
"id": "13485711",
"id": "28cfec18",
"metadata": {},
"source": [
"## Tests\n",
@ -384,7 +384,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "fbfc37d5",
"id": "a778d1c9",
"metadata": {},
"outputs": [],
"source": [
@ -394,7 +394,7 @@
},
{
"cell_type": "markdown",
"id": "d43e3179",
"id": "43717a30",
"metadata": {},
"source": [
"Neben den üblichen arithmetischen Vergleichen `==, !=, <, <= ,> ,>=` \n",
@ -404,7 +404,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "7e289c8e",
"id": "b425b2bf",
"metadata": {},
"outputs": [],
"source": [
@ -416,7 +416,7 @@
},
{
"cell_type": "markdown",
"id": "0ca8fc84",
"id": "b8b63af7",
"metadata": {},
"source": [
"## Verzweigungen\n",
@ -437,7 +437,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "6ab36f93",
"id": "759c7b60",
"metadata": {},
"outputs": [],
"source": [
@ -453,7 +453,7 @@
},
{
"cell_type": "markdown",
"id": "3247aa40",
"id": "92f05a99",
"metadata": {},
"source": [
"Einrückungen verbessern die Lesbarkeit, sind aber fakultativ. Zeilenumbrüche trennen Anweisungen. Das ist auch durch Semikolon möglich. Obiger Codeblock ist für Julia identisch zu folgender Zeile:\n"
@ -462,7 +462,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "6b6f3846",
"id": "75c38c3c",
"metadata": {},
"outputs": [],
"source": [
@ -472,7 +472,7 @@
},
{
"cell_type": "markdown",
"id": "4f8718ea",
"id": "6c916fa7",
"metadata": {},
"source": [
"Es wird dringend empfohlen, von Anfang an den eigenen Code übersichtlich mit sauberen Einrückungen zu formatieren!\n",
@ -494,7 +494,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "e2518e65",
"id": "8f6ff3c3",
"metadata": {},
"outputs": [],
"source": [
@ -507,7 +507,7 @@
},
{
"cell_type": "markdown",
"id": "3fa36879",
"id": "6ba98544",
"metadata": {},
"source": [
"## Arrays\n",
@ -518,7 +518,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "cf56b9fc",
"id": "bde3f18d",
"metadata": {},
"outputs": [],
"source": [
@ -528,7 +528,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "2e6ae1f4",
"id": "ab7ae1b1",
"metadata": {},
"outputs": [],
"source": [
@ -538,7 +538,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "18a71a80",
"id": "cd6f6101",
"metadata": {},
"outputs": [],
"source": [
@ -548,7 +548,7 @@
},
{
"cell_type": "markdown",
"id": "6833c60b",
"id": "4cd8e309",
"metadata": {},
"source": [
"Man kann leere Vektoren anlegen und sie verlängern.\n"
@ -557,7 +557,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "49a0d406",
"id": "4e643897",
"metadata": {},
"outputs": [],
"source": [
@ -569,7 +569,7 @@
},
{
"cell_type": "markdown",
"id": "ca3e6d8e",
"id": "d3e2209e",
"metadata": {},
"source": [
":::{.callout-note icon=\"false\" .titlenormal collapse=\"true\" font-variant-ligatures=\"no-contextual\" }\n",
@ -580,7 +580,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "087b10f7",
"id": "8bb956d4",
"metadata": {},
"outputs": [],
"source": [
@ -600,7 +600,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "0b8be63e",
"id": "a417e43d",
"metadata": {},
"outputs": [],
"source": [
@ -609,7 +609,7 @@
},
{
"cell_type": "markdown",
"id": "cd067cf0",
"id": "71efa254",
"metadata": {},
"source": [
":::"
@ -618,9 +618,9 @@
],
"metadata": {
"kernelspec": {
"display_name": "Julia 1.8.5",
"display_name": "Julia 1.10.2",
"language": "julia",
"name": "julia-1.8"
"name": "julia-1.10"
}
},
"nbformat": 4,

File diff suppressed because it is too large Load Diff

View File

@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "markdown",
"id": "3b9e97dc",
"id": "69149570",
"metadata": {},
"source": [
"# Ein Fallbeispiel: Der parametrisierte Datentyp PComplex\n",
@ -20,7 +20,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "b00fa817",
"id": "3ee9c4ae",
"metadata": {},
"outputs": [],
"source": [
@ -36,7 +36,7 @@
},
{
"cell_type": "markdown",
"id": "00603f51",
"id": "729a1d8e",
"metadata": {},
"source": [
"Julia stellt automatisch *default constructors* zur Verfügung:\n",
@ -60,7 +60,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "d583f845",
"id": "214480f6",
"metadata": {},
"outputs": [],
"source": [
@ -84,7 +84,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "e3d6ada4",
"id": "873d5dc6",
"metadata": {},
"outputs": [],
"source": [
@ -103,7 +103,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "55f6b7dc",
"id": "95c7386c",
"metadata": {},
"outputs": [],
"source": [
@ -112,7 +112,7 @@
},
{
"cell_type": "markdown",
"id": "99f6d6e1",
"id": "eb213995",
"metadata": {},
"source": [
"Für die explizite Angabe eines *inner constructors* müssen wir allerdings einen Preis zahlen: Die sonst von Julia bereitgestellten *default constructors* fehlen. \n",
@ -123,7 +123,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "e6c36f18",
"id": "e87d3a42",
"metadata": {},
"outputs": [],
"source": [
@ -134,7 +134,7 @@
},
{
"cell_type": "markdown",
"id": "5d77812c",
"id": "0512b019",
"metadata": {},
"source": [
"## Eine neue Schreibweise\n",
@ -165,7 +165,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "a4fc6d3c",
"id": "81818d42",
"metadata": {},
"outputs": [],
"source": [
@ -176,7 +176,7 @@
},
{
"cell_type": "markdown",
"id": "c19f6e25",
"id": "bf0863e9",
"metadata": {},
"source": [
"(Die Typ-Annotation -- `Real` statt `AbstractFloat` -- ist ein Vorgriff auf kommende weitere Konstruktoren. Im Moment funktioniert der Operator `⋖` erstmal nur mit `Float`s.)\n",
@ -188,7 +188,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "13e750ef",
"id": "4cf73e28",
"metadata": {},
"outputs": [],
"source": [
@ -206,7 +206,7 @@
},
{
"cell_type": "markdown",
"id": "e1c7d6fa",
"id": "0dae2fef",
"metadata": {},
"source": [
"## Methoden für `PComplex`\n",
@ -230,7 +230,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "373829e0",
"id": "042418fd",
"metadata": {},
"outputs": [],
"source": [
@ -241,7 +241,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "a4490292",
"id": "c20d10e5",
"metadata": {},
"outputs": [],
"source": [
@ -252,7 +252,7 @@
},
{
"cell_type": "markdown",
"id": "d49ec514",
"id": "82fe20b4",
"metadata": {},
"source": [
":::\n"
@ -261,7 +261,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "d2186aeb",
"id": "a53f0e79",
"metadata": {},
"outputs": [],
"source": [
@ -271,7 +271,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "5d93d3ca",
"id": "d6987594",
"metadata": {},
"outputs": [],
"source": [
@ -289,7 +289,7 @@
},
{
"cell_type": "markdown",
"id": "07ed8595",
"id": "53f4bb77",
"metadata": {},
"source": [
"Die Funktion `sqrt()` hat schon einige Methoden:\n"
@ -298,7 +298,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "1ecfd1ac",
"id": "f93f63c6",
"metadata": {},
"outputs": [],
"source": [
@ -307,7 +307,7 @@
},
{
"cell_type": "markdown",
"id": "f619c771",
"id": "7b4f323a",
"metadata": {},
"source": [
"Jetzt wird es eine Methode mehr:\n"
@ -316,7 +316,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "56a4ce0f",
"id": "b88cd74b",
"metadata": {},
"outputs": [],
"source": [
@ -328,7 +328,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "195204e7",
"id": "e077b8bf",
"metadata": {},
"outputs": [],
"source": [
@ -337,7 +337,7 @@
},
{
"cell_type": "markdown",
"id": "c912bcd2",
"id": "e223fdd1",
"metadata": {},
"source": [
"und nun zur Multiplikation:\n"
@ -346,7 +346,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "8c648a2d",
"id": "5537f7ec",
"metadata": {},
"outputs": [],
"source": [
@ -357,7 +357,7 @@
},
{
"cell_type": "markdown",
"id": "79074b01",
"id": "7189f0c6",
"metadata": {},
"source": [
"(Da das Operatorsymbol kein normaler Name ist, muss der Doppelpunkt bei der Zusammensetzung mit `Base.` sein.)\n",
@ -373,7 +373,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "ff3ee027",
"id": "610a38fe",
"metadata": {},
"outputs": [],
"source": [
@ -382,7 +382,7 @@
},
{
"cell_type": "markdown",
"id": "f43ef8c6",
"id": "bc39d089",
"metadata": {},
"source": [
"Wenn man in die zahlreichen Methoden schaut, die z.B. für `+` und `*` definiert sind, findet man u.a. eine Art 'catch-all-Definition'\n",
@ -408,7 +408,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "8f1d4d57",
"id": "48cae0ae",
"metadata": {},
"outputs": [],
"source": [
@ -418,7 +418,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "27c2724e",
"id": "768934ac",
"metadata": {},
"outputs": [],
"source": [
@ -428,7 +428,7 @@
},
{
"cell_type": "markdown",
"id": "8347acad",
"id": "df2672c5",
"metadata": {},
"source": [
"Die Funktion `promote()` verwendet dazu zwei Helfer, die Funktionen\n",
@ -445,7 +445,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "fe551c95",
"id": "70306adc",
"metadata": {},
"outputs": [],
"source": [
@ -454,7 +454,7 @@
},
{
"cell_type": "markdown",
"id": "e4c08732",
"id": "ec999b3a",
"metadata": {},
"source": [
"### Die Funktion `convert(T,x)`\n",
@ -466,7 +466,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "5d6aabe4",
"id": "b326a121",
"metadata": {},
"outputs": [],
"source": [
@ -476,7 +476,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "8b5205d2",
"id": "57606643",
"metadata": {},
"outputs": [],
"source": [
@ -486,7 +486,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "0d4b80ce",
"id": "a3b39504",
"metadata": {},
"outputs": [],
"source": [
@ -495,7 +495,7 @@
},
{
"cell_type": "markdown",
"id": "3e3d953b",
"id": "06251c1d",
"metadata": {},
"source": [
"Die spezielle Rolle von `convert()` liegt darin, dass es an verschiedenen Stellen _implizit_ und automatisch eingesetzt wird: \n",
@ -526,7 +526,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "2f9e1ebe",
"id": "e258330e",
"metadata": {},
"outputs": [],
"source": [
@ -558,7 +558,7 @@
},
{
"cell_type": "markdown",
"id": "c831e4c3",
"id": "ccb96089",
"metadata": {},
"source": [
"Ein Test der neuen Konstruktoren:\n"
@ -567,7 +567,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "8103dc03",
"id": "ec747779",
"metadata": {},
"outputs": [],
"source": [
@ -576,7 +576,7 @@
},
{
"cell_type": "markdown",
"id": "c85b8d7a",
"id": "fd8541cf",
"metadata": {},
"source": [
"Wir brauchen nun noch *promotion rules*, die festlegen, welcher Typ bei `promote(x::T1, y::T2)` herauskommen soll. Damit wird `promote_type()` intern um die nötigen weiteren Methoden erweitert. \n",
@ -587,7 +587,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "8e6a1e94",
"id": "806fff6a",
"metadata": {},
"outputs": [],
"source": [
@ -600,7 +600,7 @@
},
{
"cell_type": "markdown",
"id": "4ad30167",
"id": "97c7de69",
"metadata": {},
"source": [
"1. Regel:\n",
@ -617,7 +617,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "9e72f683",
"id": "cc47939d",
"metadata": {},
"outputs": [],
"source": [
@ -627,7 +627,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "f0aec53e",
"id": "63c20bc7",
"metadata": {},
"outputs": [],
"source": [
@ -636,7 +636,7 @@
},
{
"cell_type": "markdown",
"id": "0d881cc4",
"id": "e94c6b15",
"metadata": {},
"source": [
":::{.callout-caution icon=\"false\" collapse=\"true\" .titlenormal}\n",
@ -730,15 +730,9 @@
],
"metadata": {
"kernelspec": {
"display_name": "Julia 1.8.5",
"display_name": "Julia 1.10.2",
"language": "julia",
"name": "julia-1.8"
},
"language_info": {
"file_extension": ".jl",
"mimetype": "application/julia",
"name": "julia",
"version": "1.8.5"
"name": "julia-1.10"
}
},
"nbformat": 4,

View File

@ -1,7 +1,8 @@
#!/bin/bash
cp ../chapters/*.ipynb .
for i in *.ipynb
cp ../chapters/*.quarto_ipynb .
for i in *.quarto_ipynb
do
echo $i
jupyter nbconvert --inplace --clear-output --to notebook $i
echo $i
mv $i "${i%.quarto_ipynb}.ipynb"
jupyter nbconvert --inplace --clear-output --to notebook "${i%.quarto_ipynb}.ipynb"
done

View File

@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "markdown",
"id": "d56a820e",
"id": "5060b5d0",
"metadata": {},
"source": [
"# Grundlagen der Syntax\n",
@ -36,7 +36,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "ff07d3b4",
"id": "109cbcf5",
"metadata": {},
"outputs": [],
"source": [
@ -47,7 +47,7 @@
},
{
"cell_type": "markdown",
"id": "da69601f",
"id": "267dcd3c",
"metadata": {},
"source": [
"Jetzt ist natürlich der Logarithmus kaputt:\n"
@ -56,7 +56,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "88275d81",
"id": "c8432843",
"metadata": {},
"outputs": [],
"source": [
@ -66,7 +66,7 @@
},
{
"cell_type": "markdown",
"id": "5ecfdec6",
"id": "cf194eb9",
"metadata": {},
"source": [
"(siehe auch <https://stackoverflow.com/questions/65902105/how-to-reset-any-function-in-julia-to-its-original-state>)\n",
@ -92,7 +92,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "dc76d67e",
"id": "8fa53675",
"metadata": {},
"outputs": [],
"source": [
@ -102,7 +102,7 @@
},
{
"cell_type": "markdown",
"id": "6b068f1c",
"id": "07d1a5e6",
"metadata": {},
"source": [
"Das Semikolon unterdrückt das:\n"
@ -111,7 +111,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "efd01a2c",
"id": "4b79202b",
"metadata": {},
"outputs": [],
"source": [
@ -121,7 +121,7 @@
},
{
"cell_type": "markdown",
"id": "18387226",
"id": "76937fcb",
"metadata": {},
"source": [
":::\n",
@ -137,7 +137,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "41df7f55",
"id": "4af8b031",
"metadata": {},
"outputs": [],
"source": [
@ -147,7 +147,7 @@
},
{
"cell_type": "markdown",
"id": "61e668f9",
"id": "b81c022a",
"metadata": {},
"source": [
"Also geht das Folgende schief, aber leider **ohne eine Fehlermeldung**!\n"
@ -156,7 +156,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "694793eb",
"id": "74162af6",
"metadata": {},
"outputs": [],
"source": [
@ -169,7 +169,7 @@
},
{
"cell_type": "markdown",
"id": "88c64cd2",
"id": "fdaa2eed",
"metadata": {},
"source": [
"Hier wird das `+` in der zweiten Zeile als Präfix-Operator (Vorzeichen) interpretiert. Damit sind 1. und 2. Zeile jeweils für sich vollständige, korrekte Ausdrücke (auch wenn die 2. Zeile natürlich völlig nutzlos ist) und werden auch so abgearbeitet. \n",
@ -180,7 +180,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "8ec8508d",
"id": "e865958c",
"metadata": {},
"outputs": [],
"source": [
@ -191,7 +191,7 @@
},
{
"cell_type": "markdown",
"id": "1b323891",
"id": "ddd2ae7d",
"metadata": {},
"source": [
":::\n",
@ -205,7 +205,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "d733f6a2",
"id": "a628a28a",
"metadata": {},
"outputs": [],
"source": [
@ -217,7 +217,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "cf4ef498",
"id": "39f0f1fd",
"metadata": {},
"outputs": [],
"source": [
@ -238,7 +238,7 @@
},
{
"cell_type": "markdown",
"id": "e0fc09d1",
"id": "44aa6359",
"metadata": {},
"source": [
"## Datentypen Teil I \n",
@ -260,7 +260,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "0ba7db71",
"id": "f5fcc67a",
"metadata": {},
"outputs": [],
"source": [
@ -271,7 +271,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "ad90519a",
"id": "0f4c6d58",
"metadata": {},
"outputs": [],
"source": [
@ -282,7 +282,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "e36334d2",
"id": "ef084989",
"metadata": {},
"outputs": [],
"source": [
@ -293,7 +293,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "f48d35a6",
"id": "1f1df8fc",
"metadata": {},
"outputs": [],
"source": [
@ -304,7 +304,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "0eb5282b",
"id": "b833e181",
"metadata": {},
"outputs": [],
"source": [
@ -314,7 +314,7 @@
},
{
"cell_type": "markdown",
"id": "6407ce53",
"id": "610935f8",
"metadata": {},
"source": [
"- `sizeof()` liefert die Größe eines Objekts oder Typs in Bytes (1 Byte = 8 Bit)\n",
@ -332,7 +332,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "d2c3f6c8",
"id": "1b399845",
"metadata": {},
"outputs": [],
"source": [
@ -355,7 +355,7 @@
},
{
"cell_type": "markdown",
"id": "868ae573",
"id": "73a859d9",
"metadata": {},
"source": [
"Kurze Blöcke kann man in eine Zeile schreiben:\n"
@ -364,7 +364,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "76f17f5f",
"id": "ad94abc7",
"metadata": {},
"outputs": [],
"source": [
@ -373,7 +373,7 @@
},
{
"cell_type": "markdown",
"id": "ef1e84b5",
"id": "34c18e6c",
"metadata": {},
"source": [
"Der Wert eines `if`-Blocks kann natürlich zugewiesen werden:\n"
@ -382,7 +382,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "318501e9",
"id": "27eef305",
"metadata": {},
"outputs": [],
"source": [
@ -396,7 +396,7 @@
},
{
"cell_type": "markdown",
"id": "0c05b161",
"id": "0ac5ece1",
"metadata": {},
"source": [
"### Auswahloperator (ternary operator) `test ? exp1 : exp2`\n"
@ -405,7 +405,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "40e9db00",
"id": "dbe58322",
"metadata": {},
"outputs": [],
"source": [
@ -416,7 +416,7 @@
},
{
"cell_type": "markdown",
"id": "48705675",
"id": "d7e0a7f9",
"metadata": {},
"source": [
"ist äquivalent zu\n"
@ -425,7 +425,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "dadac914",
"id": "e1929004",
"metadata": {},
"outputs": [],
"source": [
@ -438,7 +438,7 @@
},
{
"cell_type": "markdown",
"id": "8d122010",
"id": "406f03e8",
"metadata": {},
"source": [
"## Vergleiche, Tests, Logische Operationen\n",
@ -458,7 +458,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "13005342",
"id": "5409328f",
"metadata": {},
"outputs": [],
"source": [
@ -467,7 +467,7 @@
},
{
"cell_type": "markdown",
"id": "dd31f487",
"id": "9b27b690",
"metadata": {},
"source": [
"Nun ja, fast alles:\n"
@ -476,7 +476,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "7491b44b",
"id": "5e6b4540",
"metadata": {},
"outputs": [],
"source": [
@ -485,7 +485,7 @@
},
{
"cell_type": "markdown",
"id": "d5eace21",
"id": "df810fec",
"metadata": {},
"source": [
"Die Fehlermeldung zeigt ein paar Grundprinzipien von Julia:\n",
@ -500,7 +500,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "6538caaf",
"id": "aa2d90be",
"metadata": {},
"outputs": [],
"source": [
@ -509,7 +509,7 @@
},
{
"cell_type": "markdown",
"id": "297ce845",
"id": "7d79d348",
"metadata": {},
"source": [
"Zuletzt noch: Vergleiche können gekettet werden.\n"
@ -518,7 +518,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "449eba70",
"id": "3de7f381",
"metadata": {},
"outputs": [],
"source": [
@ -528,7 +528,7 @@
},
{
"cell_type": "markdown",
"id": "9f4b1c41",
"id": "e5535e05",
"metadata": {},
"source": [
"### Tests \n",
@ -538,7 +538,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "18d77ec1",
"id": "1fa42721",
"metadata": {},
"outputs": [],
"source": [
@ -547,7 +547,7 @@
},
{
"cell_type": "markdown",
"id": "2dc1c0aa",
"id": "9e3772fc",
"metadata": {},
"source": [
"und vom Typ `f(s1::String, s2::String) -> Bool`\n"
@ -556,7 +556,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "ea9be46e",
"id": "a462d33f",
"metadata": {},
"outputs": [],
"source": [
@ -565,7 +565,7 @@
},
{
"cell_type": "markdown",
"id": "af8b3ce6",
"id": "ee1487a3",
"metadata": {},
"source": [
"- Die Funktion `in(item, collection) -> Bool` testet, ob `item` in `collection` ist. \n",
@ -576,7 +576,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "e811c4d8",
"id": "71790111",
"metadata": {},
"outputs": [],
"source": [
@ -587,7 +587,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "15f8ba27",
"id": "f9b92ce4",
"metadata": {},
"outputs": [],
"source": [
@ -596,7 +596,7 @@
},
{
"cell_type": "markdown",
"id": "6b811515",
"id": "93782274",
"metadata": {},
"source": [
"### Logische Operationen: `&&`, `||`, `!`\n"
@ -605,7 +605,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "ea9ad7fb",
"id": "8e907712",
"metadata": {},
"outputs": [],
"source": [
@ -614,7 +614,7 @@
},
{
"cell_type": "markdown",
"id": "a1886e91",
"id": "efb19c75",
"metadata": {},
"source": [
"#### Bedingte Auswertung (_short circuit evaluation_)\n",
@ -632,7 +632,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "a5ef06bf",
"id": "e5cae687",
"metadata": {},
"outputs": [],
"source": [
@ -647,7 +647,7 @@
},
{
"cell_type": "markdown",
"id": "bb950743",
"id": "444d49b9",
"metadata": {},
"source": [
"Natürlich kann man alle diese Tests auch Variablen vom Typ `Bool` zuordnen und\n",
@ -657,7 +657,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "8c44f3bc",
"id": "68a69b63",
"metadata": {},
"outputs": [],
"source": [
@ -671,7 +671,7 @@
},
{
"cell_type": "markdown",
"id": "b7d1e766",
"id": "e42d40c8",
"metadata": {},
"source": [
"- In Julia müssen alle Tests in einem logischen Ausdruck vom Typ `Bool` sein.\n",
@ -684,7 +684,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "0a46fa2b",
"id": "9fb43a4a",
"metadata": {},
"outputs": [],
"source": [
@ -695,7 +695,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "f56bbc75",
"id": "58faddd6",
"metadata": {},
"outputs": [],
"source": [
@ -705,7 +705,7 @@
},
{
"cell_type": "markdown",
"id": "508cebd9",
"id": "295ec49e",
"metadata": {},
"source": [
"## Schleifen *(loops)*\n",
@ -725,7 +725,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "d91b98b6",
"id": "9bd613c4",
"metadata": {},
"outputs": [],
"source": [
@ -739,7 +739,7 @@
},
{
"cell_type": "markdown",
"id": "f7edea21",
"id": "33b95f6d",
"metadata": {},
"source": [
"Der Körper einer `while`- und `for`-Schleife kann die Anweisungen `break` und `continue` enthalten. `break` stoppt die Schleife, `continue` überspringt den Rest des Schleifenkörpers und beginnt sofort mit dem nächsten Schleifendurchlauf.\n"
@ -748,7 +748,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "149c79ac",
"id": "8ef0e09b",
"metadata": {},
"outputs": [],
"source": [
@ -773,7 +773,7 @@
},
{
"cell_type": "markdown",
"id": "2e91f7a3",
"id": "ab77d5c1",
"metadata": {},
"source": [
"Mit `break` kann man auch Endlosschleifen verlassen:\n"
@ -782,7 +782,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "0b1b1ab2",
"id": "72307342",
"metadata": {},
"outputs": [],
"source": [
@ -797,7 +797,7 @@
},
{
"cell_type": "markdown",
"id": "d9bc10da",
"id": "f3032c94",
"metadata": {},
"source": [
"### `for`-Schleifen\n",
@ -818,7 +818,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "99cd73cb",
"id": "1e45bf78",
"metadata": {},
"outputs": [],
"source": [
@ -829,7 +829,7 @@
},
{
"cell_type": "markdown",
"id": "1a17064c",
"id": "e723c97a",
"metadata": {},
"source": [
"Oft benötigt man einen numerischen Schleifenzähler. Dafür gibt es das *range*-Konstrukt. Die einfachsten Formen sind \n",
@ -839,7 +839,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "3177977b",
"id": "b3a01bd4",
"metadata": {},
"outputs": [],
"source": [
@ -853,7 +853,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "0c859acc",
"id": "8427a301",
"metadata": {},
"outputs": [],
"source": [
@ -863,7 +863,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "c31d91f6",
"id": "f973a1cb",
"metadata": {},
"outputs": [],
"source": [
@ -873,7 +873,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "c35be84d",
"id": "63290cd9",
"metadata": {},
"outputs": [],
"source": [
@ -882,7 +882,7 @@
},
{
"cell_type": "markdown",
"id": "19034238",
"id": "419963f0",
"metadata": {},
"source": [
"#### Geschachtelte Schleifen _(nested loops)_\n",
@ -893,7 +893,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "9be68ac5",
"id": "06ab8236",
"metadata": {},
"outputs": [],
"source": [
@ -909,7 +909,7 @@
},
{
"cell_type": "markdown",
"id": "99328006",
"id": "19464d7e",
"metadata": {},
"source": [
"Man kann *nested loops* auch in einer `for`-Anweisung zusammenfassen. Dann beendet ein `break` die Gesamtschleife.\n"
@ -918,7 +918,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "e437369c",
"id": "e208b54c",
"metadata": {},
"outputs": [],
"source": [
@ -932,7 +932,7 @@
},
{
"cell_type": "markdown",
"id": "e995a233",
"id": "e5f41344",
"metadata": {},
"source": [
":::{.callout-important .titlenormalxx}\n",
@ -944,7 +944,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "2d2e2164",
"id": "c903a887",
"metadata": {},
"outputs": [],
"source": [
@ -957,7 +957,7 @@
},
{
"cell_type": "markdown",
"id": "6c940891",
"id": "68db2918",
"metadata": {},
"source": [
"-------\n",
@ -1004,7 +1004,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "9d8ee587",
"id": "6b3cf482",
"metadata": {},
"outputs": [],
"source": [
@ -1014,7 +1014,7 @@
},
{
"cell_type": "markdown",
"id": "4a3975ec",
"id": "2009bbff",
"metadata": {},
"source": [
"Hier wird die Eingabe als Gleitkommazahl interpretiert -- und `3E+2` oder `3f+2` (Float32) ebenso. \n"
@ -1023,7 +1023,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "fa68ebcd",
"id": "d1812cfd",
"metadata": {},
"outputs": [],
"source": [
@ -1032,7 +1032,7 @@
},
{
"cell_type": "markdown",
"id": "d3b54ba7",
"id": "6cf09a01",
"metadata": {},
"source": [
"Ein Leerzeichen schafft Eindeutigkeit:\n"
@ -1041,7 +1041,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "378e3e06",
"id": "e6104540",
"metadata": {},
"outputs": [],
"source": [
@ -1050,7 +1050,7 @@
},
{
"cell_type": "markdown",
"id": "d23bc72e",
"id": "5215cde4",
"metadata": {},
"source": [
"Das funktioniert:\n"
@ -1059,7 +1059,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "ab2811f6",
"id": "6828cede",
"metadata": {},
"outputs": [],
"source": [
@ -1069,7 +1069,7 @@
},
{
"cell_type": "markdown",
"id": "c81689d3",
"id": "5316e342",
"metadata": {},
"source": [
"...und das nicht. `0x`, `0o`, `0b` wird als Anfang einer Hexadezimal-, Oktal- bzw. Binärkonstanten interpretiert.\n"
@ -1078,7 +1078,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "a5eff7fc",
"id": "d8ff4514",
"metadata": {},
"outputs": [],
"source": [
@ -1087,7 +1087,7 @@
},
{
"cell_type": "markdown",
"id": "ac739eda",
"id": "d2df69d1",
"metadata": {},
"source": [
"- Es gibt noch ein paar andere Fälle, bei denen die sehr kulante Syntax zu Überraschungen führt.\n"
@ -1096,7 +1096,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "a69f9e83",
"id": "02e802cf",
"metadata": {},
"outputs": [],
"source": [
@ -1108,7 +1108,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "3d9dc81e",
"id": "227c2b1d",
"metadata": {},
"outputs": [],
"source": [
@ -1117,7 +1117,7 @@
},
{
"cell_type": "markdown",
"id": "89722987",
"id": "b14d28e3",
"metadata": {},
"source": [
"Julia interpretiert das als Vergleich `Wichtig != 88`.\n",
@ -1128,7 +1128,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "87a6cfd7",
"id": "41460c8d",
"metadata": {},
"outputs": [],
"source": [
@ -1138,7 +1138,7 @@
},
{
"cell_type": "markdown",
"id": "90ae7dac",
"id": "8c7a3ede",
"metadata": {},
"source": [
"- Operatoren der Form `.*`, `.+`,... haben in Julia eine spezielle Bedeutung (*broadcasting*, d.h., vektorisierte Operationen). \n"
@ -1147,7 +1147,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "538cd36e",
"id": "1d6f31aa",
"metadata": {},
"outputs": [],
"source": [
@ -1156,7 +1156,7 @@
},
{
"cell_type": "markdown",
"id": "7f39acd9",
"id": "1ffdeba1",
"metadata": {},
"source": [
"Wieder gilt: Leerzeichen schaffen Klarheit!\n"
@ -1165,7 +1165,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "45ceb4be",
"id": "350fe2e3",
"metadata": {},
"outputs": [],
"source": [
@ -1175,9 +1175,9 @@
],
"metadata": {
"kernelspec": {
"display_name": "Julia 1.8.5",
"display_name": "Julia 1.10.2",
"language": "julia",
"name": "julia-1.8"
"name": "julia-1.10"
}
},
"nbformat": 4,

File diff suppressed because it is too large Load Diff