Rust und Racket
This commit is contained in:
+6
-7
@@ -82,7 +82,7 @@
|
|||||||
|
|
||||||
## Arrows
|
## Arrows
|
||||||
| LaTeX | Preview | Typst (Textual) | Typst (Shorthand) |
|
| LaTeX | Preview | Typst (Textual) | Typst (Shorthand) |
|
||||||
| --------------------- | ------- | ----------------------- | ----------------- |
|
| --------------------- | --------------------- | --------------------- | ----------------- |
|
||||||
| `\leftarrow` | $\leftarrow$ | arrow.l | <- |
|
| `\leftarrow` | $\leftarrow$ | arrow.l | <- |
|
||||||
| `\gets` | $\gets$ | arrow.l | <- |
|
| `\gets` | $\gets$ | arrow.l | <- |
|
||||||
| `\rightarrow` | $\rightarrow$ | arrow.r | -> |
|
| `\rightarrow` | $\rightarrow$ | arrow.r | -> |
|
||||||
@@ -91,7 +91,7 @@
|
|||||||
| `\Leftarrow` | $\Leftarrow$ | arrow.l.double | |
|
| `\Leftarrow` | $\Leftarrow$ | arrow.l.double | |
|
||||||
| `\Rightarrow` | $\Rightarrow$ | arrow.r.double | => |
|
| `\Rightarrow` | $\Rightarrow$ | arrow.r.double | => |
|
||||||
| `\Leftrightarrow` | $\Leftrightarrow$ | arrow.l.r.double | <=> |
|
| `\Leftrightarrow` | $\Leftrightarrow$ | arrow.l.r.double | <=> |
|
||||||
| `\mapsto` | $\mapsto$ | arrow.r.bar | |-> |
|
| `\mapsto` | $\mapsto$ | arrow.r.bar | -> |
|
||||||
| `\hookleftarrow` | $\hookleftarrow$ | arrow.l.hook | |
|
| `\hookleftarrow` | $\hookleftarrow$ | arrow.l.hook | |
|
||||||
| `\leftharpoonup` | $\leftharpoonup$ | harpoon.lt | |
|
| `\leftharpoonup` | $\leftharpoonup$ | harpoon.lt | |
|
||||||
| `\leftharpoondown` | $\leftharpoondown$ | harpoon.lb | |
|
| `\leftharpoondown` | $\leftharpoondown$ | harpoon.lb | |
|
||||||
@@ -146,9 +146,12 @@
|
|||||||
## Verschiedene Symbole
|
## Verschiedene Symbole
|
||||||
|
|
||||||
| LaTeX | Preview | Typst (Textual) | Typst (Shorthand) |
|
| LaTeX | Preview | Typst (Textual) | Typst (Shorthand) |
|
||||||
| ------ | ------- | --------------- | ----------------- |
|
| -------- | -------- | --------------- | ----------------- |
|
||||||
| `\Cap` | $\Cap$ | inter.double | |
|
| `\Cap` | $\Cap$ | inter.double | |
|
||||||
| `\Cup` | $\Cup$ | union.double | |
|
| `\Cup` | $\Cup$ | union.double | |
|
||||||
|
| `\Join` | $\Join$ | join | |
|
||||||
|
| `\aleph` | $\aleph$ | alef | |
|
||||||
|
| | | | |
|
||||||
|
|
||||||
# Temp
|
# Temp
|
||||||
|
|
||||||
@@ -156,10 +159,6 @@
|
|||||||
|
|
||||||
| LaTeX | Preview | Typst (Textual) | Typst (Shorthand) |
|
| LaTeX | Preview | Typst (Textual) | Typst (Shorthand) |
|
||||||
| -------------------- | ------- | ------------------ | ----------------- |
|
| -------------------- | ------- | ------------------ | ----------------- |
|
||||||
| `\Cap` | ⋒ | `inter.double` | `` |
|
|
||||||
| `\Cup` | ⋓ | `union.double` | `` |
|
|
||||||
| `\Join` | ⋈ | `join` | `` |
|
|
||||||
| `\aleph` | ℵ | `alef` | `` |
|
|
||||||
| `\angle` | ∠ | `angle` | `` |
|
| `\angle` | ∠ | `angle` | `` |
|
||||||
| `\approx` | ≈ | `approx` | `` |
|
| `\approx` | ≈ | `approx` | `` |
|
||||||
| `\approxeq` | ≊ | `approx.eq` | `` |
|
| `\approxeq` | ≊ | `approx.eq` | `` |
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
```racket
|
||||||
|
#lang racket
|
||||||
|
|
||||||
|
; https://dev.to/goober99/learn-racket-by-example-gui-programming-3epm
|
||||||
|
|
||||||
|
(require racket/gui/base)
|
||||||
|
|
||||||
|
; 1. Hauptfenster (Frame) erstellen
|
||||||
|
(define frame (new frame% [label "Hallo Racket"]
|
||||||
|
[width 300]
|
||||||
|
[height 200]))
|
||||||
|
|
||||||
|
; 2. Einen Button zum Fenster hinzufügen
|
||||||
|
(define btn (new button% [parent frame]
|
||||||
|
[label "Klick mich"]
|
||||||
|
[callback (lambda (b e)
|
||||||
|
(printf "Button wurde geklickt!\n"))]))
|
||||||
|
|
||||||
|
; 3. Fenster sichtbar machen
|
||||||
|
(send frame show #t)
|
||||||
|
```
|
||||||
@@ -13,7 +13,7 @@ https://serverdiscounter.com/blog/2026-01-26-regex-grundlagen
|
|||||||
## Special Characters
|
## Special Characters
|
||||||
|
|
||||||
| | |
|
| | |
|
||||||
| -------- | ------------------------------------------------------------------------------- |
|
| ---------- | ------------------------------------------------------------------------------- |
|
||||||
| `\` | Escapet Sonderzeichen oder kennzeichnet eine spezielle Sequenz |
|
| `\` | Escapet Sonderzeichen oder kennzeichnet eine spezielle Sequenz |
|
||||||
| `.` | Entspricht einem beliebigen einzelnen Zeichen mit Ausnahme eines Zeilenumbruchs |
|
| `.` | Entspricht einem beliebigen einzelnen Zeichen mit Ausnahme eines Zeilenumbruchs |
|
||||||
| `^` | Matches the start of the string. |
|
| `^` | Matches the start of the string. |
|
||||||
@@ -28,14 +28,19 @@ https://serverdiscounter.com/blog/2026-01-26-regex-grundlagen
|
|||||||
| `{m}` | Matches exactly m many repetitions of the previous RE. |
|
| `{m}` | Matches exactly m many repetitions of the previous RE. |
|
||||||
| `{m,n}` | Greedily matches from m many to n many repetitions of the previous RE. |
|
| `{m,n}` | Greedily matches from m many to n many repetitions of the previous RE. |
|
||||||
| `{m,n}?` | Matches m many to n many repetitions of the previous RE. |
|
| `{m,n}?` | Matches m many to n many repetitions of the previous RE. |
|
||||||
|
| `[...]` | Indicates a set of characters to match. |
|
||||||
|
| `[amk]` | Matches 'a', 'm', or 'k'. |
|
||||||
|
| [a-z] | Matches 'a' through 'z'. |
|
||||||
|
| `[a-f0-7]` | Matches 'a' through 'f' or '0' through '7'. |
|
||||||
|
| `[a\-z]` | Matches 'a', '-', or 'z'. |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
[...] Indicates a set of characters to match.
|
|
||||||
[amk] Matches 'a', 'm', or 'k'.
|
|
||||||
[a-z] Matches 'a' through 'z'.
|
|
||||||
[a-f0-7] Matches 'a' through 'f' or '0' through '7'.
|
|
||||||
[a\-z] Matches 'a', '-', or 'z'.
|
|
||||||
[a-] Matches 'a' or '-'.
|
[a-] Matches 'a' or '-'.
|
||||||
[-a] Matches 'a' or '-'.
|
[-a] Matches 'a' or '-'.
|
||||||
[(+*)] Matches '(', '+', '*', or ')'. [] matches special characters literally.
|
[(+*)] Matches '(', '+', '*', or ')'. [] matches special characters literally.
|
||||||
|
|||||||
@@ -8,7 +8,71 @@ In Rust verwenden wir das Makro `println!()`, um eine Ausgabe auf der Konsole au
|
|||||||
|
|
||||||
Sehen wir uns das „Hello World!“-Programm in Rust an:
|
Sehen wir uns das „Hello World!“-Programm in Rust an:
|
||||||
|
|
||||||
```fn main() {
|
```rust
|
||||||
|
fn main() {
|
||||||
println!(„Hello World!“);
|
println!(„Hello World!“);
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
## Kommentare
|
||||||
|
|
||||||
|
**Comments** sind Notizen, die man in den Code schreibt. Der compiler ignoriert sie vollständig – sie existieren nur, um Menschen beim Verständnis des Codes zu helfen.
|
||||||
|
|
||||||
|
Um einen einzeiligen Kommentar zu schreiben, verwendet man `//`. Alles nach `//` bis zum Ende der Zeile wird ignoriert:
|
||||||
|
|
||||||
|
```rust
|
||||||
|
// Das ist ein Kommentarprintln!("Hello, world!");
|
||||||
|
```
|
||||||
|
|
||||||
|
Ein Kommentar kann auch am Ende einer Zeile nach dem Code geschrieben werden:
|
||||||
|
|
||||||
|
```rust
|
||||||
|
println!("Hello, world!"); // Dies gibt Hello, world! aus!
|
||||||
|
```
|
||||||
|
|
||||||
|
Für Kommentare, die sich über mehrere Zeilen erstrecken, verwendet man `/*`, um zu beginnen, und `*/`, um zu enden:
|
||||||
|
|
||||||
|
```rust
|
||||||
|
/* Dies ist ein mehrzeiliger Kommentar. Der Compiler ignoriert ihn vollständig. */println!("Welcome!");
|
||||||
|
```
|
||||||
|
|
||||||
|
Kommentare können eine Codezeile auch vorübergehend **deaktivieren**, ohne sie zu löschen:
|
||||||
|
|
||||||
|
```rust
|
||||||
|
// println!("This line will NOT run");println!("This line will run");
|
||||||
|
```
|
||||||
|
|
||||||
|
**Hinweis:** Jeder mehrzeilige Kommentar, der mit `/*` beginnt, muss mit `*/` geschlossen werden, andernfalls behandelt der Compiler alles danach als Kommentar.
|
||||||
|
|
||||||
|
Grundlegende Programmstruktur
|
||||||
|
|
||||||
|
In Rust beginnt jedes ausführbare Programm mit der Funktion `main`. Diese Funktion ist der Einstiegspunkt des Programms und dort beginnt die Ausführung.
|
||||||
|
|
||||||
|
Die `function` `main` wird mit dem Schlüsselwort `fn`definiert, gefolgt von `main` und einem Klammerpaar `()`. Der auszuführende Code wird innerhalb geschweifter Klammern `{}` platziert.
|
||||||
|
|
||||||
|
Hier ist eine einfache Aufschlüsselung eines grundlegenden Rust-Programms:
|
||||||
|
|
||||||
|
```rust
|
||||||
|
fn main() { // Hauptfunktion println!("Hello, Coddy!"); // Ausgabeanweisung}
|
||||||
|
```
|
||||||
|
|
||||||
|
Wichtiger Hinweis: In Rust muss jede Anweisung mit einem Semikolon (`;`) enden. Das Semikolon ist obligatorisch und teilt Rust mit, dass du das Ende einer Anweisung erreicht hast.
|
||||||
|
|
||||||
|
Wenn du vergisst, ein Semikolon hinzuzufügen, führt dies zu einem Kompilierungsfehler. Beachte jedoch, dass Codeblöcke, die in geschweiften Klammern {} eingeschlossen sind (wie Funktionsdeklarationen), keine Semikolons benötigen.
|
||||||
|
|
||||||
|
## Grundlegende Programmstruktur
|
||||||
|
|
||||||
|
In Rust beginnt jedes ausführbare Programm mit der Funktion `main`. Diese Funktion ist der Einstiegspunkt des Programms und dort beginnt die Ausführung.
|
||||||
|
|
||||||
|
Die `function` `main` wird mit dem Schlüsselwort `fn`definiert, gefolgt von `main` und einem Klammerpaar `()`. Der auszuführende Code wird innerhalb geschweifter Klammern `{}` platziert.
|
||||||
|
|
||||||
|
Hier ist eine einfache Aufschlüsselung eines grundlegenden Rust-Programms:
|
||||||
|
|
||||||
|
```rust
|
||||||
|
fn main() { // Hauptfunktion
|
||||||
|
println!("Hello, Coddy!"); // Ausgabeanweisung
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Wichtiger Hinweis: In Rust muss jede Anweisung mit einem Semikolon (`;`) enden. Das Semikolon ist obligatorisch und teilt Rust mit, dass du das Ende einer Anweisung erreicht hast.
|
||||||
|
|
||||||
|
Wenn du vergisst, ein Semikolon hinzuzufügen, führt dies zu einem Kompilierungsfehler. Beachte jedoch, dass Codeblöcke, die in geschweiften Klammern `{}` eingeschlossen sind (wie Funktionsdeklarationen), keine Semikolons benötigen.
|
||||||
|
|||||||
Reference in New Issue
Block a user