Category Theory (updating)

Definition of a category Objects and arrows exist. There should be identity arrows for all objects. Arrows should be composited. Associativity holds. The arrows are also called morphisms. Terminology: domain and codomain $\mathrm{dom}(f)\xrightarrow{f} \mathrm{cod}(f)$ Directed graphs and categories If $f:A\rightarrow B$ and $g:B\rightarrow C$ exist but $h := g\cdot f$ doesn’t, it violates the rule of composition. Hence the graphs are not categories in general. Initial object An initial object of a category $C$ is an object $I$ in $C$ such that for every object $X$ in $C$, there exists precisely one morphism $I \rightarrow X$.

Galois Theory (almost done)

Before the lecture Motivation My motivation was to understand why there is no solution in radicals to general polynomial equations of degree five or higher with arbitrary coefficients (Abel-Ruffini theorem). I knew the fact but never had a chance to learn it. But I was so curious about it these days, and decided to check. About learning material YouTube video “Visual Group Theory - Lecture 6” was easy to understand.

Tried to allocate array dynamically with const generics (Rust)

Since v1.51, const generic feature was officially released. static and const https://web.mit.edu/rust-lang_v1.25/arch/amd64_ubuntu1404/share/doc/rust/html/book/first-edition/const-and-static.html static Rust provides a ‘global variable’ sort of facility in static items. They’re similar to constants, but static items aren’t inlined upon use. This means that there is only one instance for each value, and it’s at a fixed location in memory. const Constants live for the entire lifetime of a program. More specifically, constants in Rust have no fixed address in memory.

Yew Tutorial (v0.19) - part 2

I continued learning Yew after [this post]({{< ref “rust/yew_tutorial_1.md” >}}). Important warning As of Feb. 12 2022, I’ve followed/referred the “Next” version of the Yew documentation (not only v0.19) because there are lots of changes. And I found this statement: You are currently reading about function components - the recommended way to write components when starting with Yew. But we have to note that there is a more advanced, but less recommended way to write them - Struct components

Yew Tutorial (v0.19) - part 1

Before Yew tutorial I want to try with wasm-pack, but after several tries, I realized that it was a bad try. And most parts of the official document uses Trunk, so I was back to Trunk. Please refer to my post about Trunk. Versions Cargo: 1.65 Yew: 0.19 Set up Rust environment for Yew rustup target add wasm32-unknown-unknown cargo install trunk My summary on Yew tutorial page I followed the official “Video page” tutorial.

Trunk (WASM bundler for Rust) - Tutorial

Try Trunk before Yew tutorial Just follow the simplest official tutorial To understand how Trunk behaves. I’ve simply followed the official getting started. Set up: cargo install trunk cargo new trunk-tutorial cd trunk-tutorial Keep the default Hello world code in src/main.rs. Create index.html: <html> <head> <link data-trunk rel="scss" href="index.scss"/> </head> </html> Create empty index.scss, and bild: trunk build Feb 03 18:59:17.553 INFO 📦 starting build Feb 03 18:59:17.555 INFO spawning asset pipelines Feb 03 18:59:17.

Builder pattern in Rust

https://rust-unofficial.github.io/patterns/patterns/creational/builder.html TL;DR Construct an object with calls to a builder helper. Explain with Rust example: step by step I guess this Pasta example is a bad example… need to be improved Suppose you define a new struct (I use &str because it is just a snippet, but in real code, you should use String in this case): struct Pasta<'a> { name: &'a str, tomato: bool, garlic: bool, special_order: &'a str } You can create/initialize an object like below:

"Type-Driven API Design (Rust)" - my note

I followed this YouTube video to learn “Type-Driven API Design”. This note was created during review so that I could extract/summarize knowledge I didn’t know before. Define your custom trait for all types In this video, the author want to implement progess function for a type which is an associated type Item of iterator. By using impl<T> MyTrait for T, you can implement the trait for all types in its scope.

Strategy design pattern in Rust

I just followed Rust Design Pattern - Strategy (aka Policy). Simple explanation Make code abstract as possible. … given an algorithm solving a particular problem, we define only the skeleton of the algorithm at an abstract level, and we separate the specific algorithm’s implementation into different parts. The stragety pattern are used frequently with dependency inversion (it is also related with high level modules). Example Code use std::collections::HashMap; type Data = HashMap<String, u32>; trait Formatter { fn format(&self, data: &Data, buf: &mut String); } struct Report; impl Report { fn generate<T: Formatter>(g: T, s: &mut String) { let mut data = HashMap::new(); data.

Rust - My note of Getting Started (19/21)

What’s this page? As of Dec. 2021, I work as a DevOps engineer, but I like to solve problems with codes (front, back, whatever. it depends on the purposes.) Thesedays, my motivation about learning Rust surged enough. This page is my memo while I’ve learned with Rust official document so that I can easily remind/refer to the key feafures. Most part of this post consist of quotes from the document, but I also leave my opinions (could be wrong.