Skip to content

Commit 3def69c

Browse files
committed
2025-11-27 rustaician notes
1 parent 963f5c4 commit 3def69c

File tree

6 files changed

+83
-5
lines changed

6 files changed

+83
-5
lines changed

journals/2025_11_27.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,10 @@
1010
- [[Rust/prelude]]
1111
- [[Rust/use]]
1212
- [[Rust/std/result/Result]] - Result enum, its variants, methods, and usage patterns
13-
- [[Programming/Enum]] - general enum concept; implementations across multiple languages
13+
- [[Programming/Enum]] - general enum concept; implementations across multiple languages
14+
- [[Rust/Trait]]
15+
- [[Rust/crate/rand/Rng]]
16+
- [[cargo/doc/--open]] can build the documentation for your deps and open it in your browser. Cool!
17+
- [[Rust/match]]
18+
- [[Programming/Pattern Matching]] - created general pattern matching concept documentation
19+
-

pages/Anthropic___Model___Claude___4.5___Opus.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
---
21
alias:: [[claude-opus-4-5]], [[claude-opus-4.5]]
32
tags:: [[AI/Model]]
4-
---
53

64
- # [Claude Opus 4.5](https://www.anthropic.com/claude/opus)
75
- ## Key Features
@@ -60,5 +58,4 @@ tags:: [[AI/Model]]
6058
- ## References
6159
- [Official documentation](https://www.anthropic.com/claude/opus)
6260
- [Claude in Microsoft Foundry](https://docs.claude.com/en/docs/build-with-claude/claude-in-microsoft-foundry)
63-
- [Claude Opus 4.5 in Amazon Bedrock](https://aws.amazon.com/blogs/machine-learning/claude-opus-4-5-now-in-amazon-bedrock/)
64-
61+
- [Claude Opus 4.5 in Amazon Bedrock](https://aws.amazon.com/blogs/machine-learning/claude-opus-4-5-now-in-amazon-bedrock/)
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
- # Pattern Matching
2+
- A fundamental concept in programming that enables the examination and deconstruction of data structures based on their form
3+
- Allows developers to specify patterns to which data should conform
4+
- Facilitates concise and readable code for data extraction, transformation, and control flow
5+
- ## Definition
6+
- Involves checking a given sequence of tokens or data structures for the presence of constituents of some pattern
7+
- Unlike pattern recognition, which may allow approximate matches, pattern matching typically requires an exact match
8+
- Patterns can take the form of sequences or tree structures
9+
- ## Key Capabilities
10+
- **Locating patterns within data**: Finding specific structures or values
11+
- **Extracting components**: Destructuring data structures to access their parts
12+
- **Substituting matching patterns**: Replacing matched patterns with other sequences
13+
- **Control flow**: Directing program execution based on data structure
14+
- ## Language Implementations
15+
- ### Functional Languages
16+
- **Haskell, ML, Scala**: Use pattern matching extensively to destructure data types and control program flow
17+
- Pattern matching is often used in function definitions
18+
- Example (Haskell):
19+
- ~~~haskell
20+
factorial 0 = 1
21+
factorial n = n * factorial (n - 1)
22+
~~~
23+
- ### Object-Oriented Languages
24+
- **C#**: Introduced pattern matching in C# 7.0 for switch statements and expressions
25+
- **Java**: Added pattern matching features to enhance type checking and data extraction
26+
- ### Systems Languages
27+
- **Rust**: Uses pattern matching extensively with `match` expressions for safe data handling
28+
- **Swift**: Incorporates pattern matching for safer and more expressive code constructs
29+
- ### Scripting Languages
30+
- **Python**: Python 3.10 introduced structural pattern matching with `match`/`case` statements
31+
- Example (Python):
32+
- ~~~python
33+
match command:
34+
case ["move", x, y]:
35+
move_to(x, y)
36+
case ["draw", shape]:
37+
draw_shape(shape)
38+
case _:
39+
print("Unknown command")
40+
~~~
41+
- ## Historical Context
42+
- **Early Implementations**: Languages like SNOBOL (1962) and COMIT (1957) were among the first to introduce pattern matching, primarily for string manipulation
43+
- **Functional Programming**: The ML language (1973) and its successors integrated pattern matching as a core feature
44+
- **Modern Developments**: Many modern languages have incorporated pattern matching to provide safer and more expressive code constructs
45+
- ## Common Use Cases
46+
- **Destructuring**: Extracting values from complex data structures (tuples, structs, enums)
47+
- **Type checking**: Handling different types or variants in a type-safe manner
48+
- **Control flow**: Replacing if-else chains or switch statements with more expressive pattern-based logic
49+
- **Error handling**: Matching on error types and success cases
50+
- **Data transformation**: Converting between different data representations
51+
- ## Related
52+
- [[Rust/match]] - Pattern matching in Rust using `match` expressions
53+
- [[Programming/Enum]] - Enums are often used with pattern matching
54+
- [[Programming/Language/Feature]] - Pattern matching as a language feature
55+
- Functional programming concepts
56+

pages/Rust___Trait.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
- like an Interface in [[Java]] or [[Py/Protocol]]
2+
- seems to be usually upper-cased like [[Rust/crate/rand/Rng]]
3+
- In this case, could think of Rng (Random Number Generator) like [[POSIX]]; it's a standard interface for which there are many distributions or variations
4+
- [Programming a Guessing Game - The Rust Programming Language](https://rust-book.cs.brown.edu/ch02-00-guessing-game-tutorial.html)
5+
- > This [`gen_range`] method is defined by the `Rng` trait that we brought into scope with the `use rand::Rng;` statement
6+
-
7+
-

pages/Rust___crate___rand___Rng.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
- [Rng in rand - Rust](https://rust-random.github.io/rand/rand/trait.Rng.html)
2+
- Random Number Generator

pages/Rust___match.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
- [`match`](https://rust-book.cs.brown.edu/ch06-02-match.html) expressions do [[Programming/Pattern Matching]]
2+
- consists of "arms"
3+
- example
4+
- ```rust
5+
match guess.cmp(&secret_number) {
6+
Ordering::Less => println!("Too small!"),
7+
Ordering::Greater => println!("Too big!"),
8+
Ordering::Equal => println!("You win!"),
9+
}
10+
```

0 commit comments

Comments
 (0)