diff --git a/notes/.obsidian/plugins/obsidian-to-anki-plugin/data.json b/notes/.obsidian/plugins/obsidian-to-anki-plugin/data.json index b2fd3fa..4d24aee 100644 --- a/notes/.obsidian/plugins/obsidian-to-anki-plugin/data.json +++ b/notes/.obsidian/plugins/obsidian-to-anki-plugin/data.json @@ -219,7 +219,9 @@ "saved-registers.png", "local-variables.png", "arg-build-area.png", - "stack-frame.png" + "stack-frame.png", + "buffer-overflow.png", + "infinite-cartesian-product.png" ], "File Hashes": { "algorithms/index.md": "3ac071354e55242919cc574eb43de6f8", @@ -331,10 +333,10 @@ "_journal/2024-02/2024-02-21.md": "f423137ae550eb958378750d1f5e98c7", "_journal/2024-02-23.md": "219ce9ad15a8733edd476c97628b71fd", "_journal/2024-02/2024-02-22.md": "312e55d57868026f6e80f7989a889c2b", - "c17/strings.md": "e909daa71ad93bcb38edbe30bc0516ac", + "c17/strings.md": "c876fc99f9980b4cb2bd9abb6b821322", "c17/index.md": "611dd21439d56575172ef004c7635382", "c17/escape-sequences.md": "a8b99070336878b4e8c11e9e4525a500", - "c17/declarations.md": "c520b5335cbcad3cf54590bf100fafbc", + "c17/declarations.md": "c853b9584365ba69ac5845082061a8dd", "algorithms/sorting/merge-sort.md": "6506483f7df6507cee0407bd205dbedd", "_journal/2024-02-24.md": "9bb319d5014caf962a9ce3141076cff4", "_journal/2024-02/2024-02-23.md": "0aad297148e8cc4058b48b7e45787ca7", @@ -458,7 +460,7 @@ "_journal/2024-04/2024-04-14.md": "037c77d0e11f2d58ffee61ea0a1708ab", "_journal/2024-04-16.md": "0bf6e2f2a3afab73d528cee88c4c1a92", "_journal/2024-04/2024-04-15.md": "256253b0633d878ca58060162beb7587", - "algebra/polynomials.md": "da56d2d6934acfa2c6b7b2c73c87b2c7", + "algebra/polynomials.md": "0ee5defa02562263fbeb08ca3ea513fb", "algebra/sequences/delta-constant.md": "b744b0d8decdfff4ad40b07af848bf74", "_journal/2024-04-19.md": "a293087860a7f378507a96df0b09dd2b", "_journal/2024-04/2024-04-18.md": "f6e5bee68dbef90a21ca92a846930a88", @@ -560,7 +562,7 @@ "_journal/2024-05/2024-05-25.md": "3e8a0061fa58a6e5c48d12800d1ab869", "_journal/2024-05-27.md": "b36636d10eab34380f17f288868df3ae", "_journal/2024-05/2024-05-26.md": "abe84b5beae74baa25501c818e64fc95", - "algebra/set.md": "a89ada021de83240724adb70490e3472", + "algebra/set.md": "e31026e860182bf000af60e4b5f39413", "algebra/boolean.md": "c9bd5abb601be6d2bedd24d5f54848b0", "git/merge-conflicts.md": "761ad6137ec51d3877f7d5b3615ca5cb", "_journal/2024-05-28.md": "0f6aeb5ec126560acdc2d8c5c6570337", @@ -613,10 +615,10 @@ "_journal/2024-06/2024-06-13.md": "e2722a00585d94794a089e8035e05728", "set/functions.md": "f10998cb17657526363f57c077f7a6f1", "_journal/2024-06-15.md": "92cb8dc5c98e10832fb70c0e3ab3cec4", - "_journal/2024-06/2024-06-14.md": "5d12bc272238ac985a1d35d3d63ea307", + "_journal/2024-06/2024-06-14.md": "8bbe0e1ca371756b91eec66af73911ce", "lambda-calculus/beta-reduction.md": "0935987f2bac0e6298735f2b26fd5885", "_journal/2024-06-16.md": "ded6ab660ecc7c3dce3afd2e88e5a725", - "_journal/2024-06/2024-06-15.md": "c3a55549da9dfc2770bfcf403bf5b30b", + "_journal/2024-06/2024-06-15.md": "2856849832ac7cb31f4f46543f5c52b4", "_journal/2024-06-17.md": "63df6757bb3384e45093bf2b9456ffac", "_journal/2024-06/2024-06-16.md": "ded6ab660ecc7c3dce3afd2e88e5a725", "_journal/2024-06-18.md": "927e8a3329deadb685ac58241066fdae", @@ -633,8 +635,8 @@ "_journal/2024-06-22.md": "8f566883a70458a20d9c750065ce4025", "programming/ars.md": "a62db41d53a0ec5973742a09e0b48f0a", "_journal/2024-06-23.md": "72e157bbf19d2d35843873ff9e900927", - "_journal/2024-06/2024-06-22.md": "6b55e35f56e7f7c296c8df6812ba62d3", - "_journal/2024-06/2024-06-21.md": "12e37e2c57abab09c781b32793fbbe1a", + "_journal/2024-06/2024-06-22.md": "ac2cb452949188d3d31e0bb1e776c2cb", + "_journal/2024-06/2024-06-21.md": "4c6b3ce619a63c758e381b51b43d0c08", "startups/financing.md": "1978def9644211c989564faa3e4a56ea", "_journal/2024-06-24.md": "7fc0f4cd231ef7cd6aa2b556d1244cf4", "_journal/2024-06/2024-06-23.md": "9e23344bcc6c9ecc038c349022eaffd7", @@ -687,7 +689,7 @@ "_journal/2024-07-17.md": "e0371a91e99f131e7258cc82c2a04cc8", "_journal/2024-07/2024-07-16.md": "149222eab7a7f58993b8e4dc8a3fb884", "_journal/2024-07-18.md": "a9d26ce938228973f07178a15128a681", - "_journal/2024-07/2024-07-17.md": "0c816cd6110bdd14d3eac4e5b82510cf", + "_journal/2024-07/2024-07-17.md": "61fed0ae4d036c8ac4477cdbd039d19f", "ontology/dialetheism.md": "56dd05b38519f90c5cab93637978b3b3", "abstract-rewriting-systems/index.md": "b7486b7635cb0d8bafc2a2f095af90fb", "abstract-rewriting-systems/normal-form.md": "2fff9a1d85bca0a2941a54b0084a0309", @@ -798,7 +800,7 @@ "c17/basic-types.md": "7c6653bf6dc24c2f2aa72fc95c4f7875", "c17/types/simple.md": "44d56a2998f3bba578f14672c8b0ee3c", "c17/types/enumerated.md": "e1f70a30677c776b7b44ac3e0ff4e76d", - "c17/types/derived.md": "26bcaee99aba7720fd76d92e10770933", + "c17/types/derived.md": "dcac68790016190ce5c4196bd9c1d53d", "c17/types/basic.md": "5064e21e683c0218890058882e06b6f3", "c17/types/index.md": "14b651bcfc8b2d62ffd200a74a9a2a6b", "_journal/2024-08-25.md": "e73a8edbd027d0f1a39289540eb512f2", @@ -879,7 +881,7 @@ "_journal/2024-10/2024-10-06.md": "65a8e538144f59ee9e7296110cc9aa14", "_journal/2024-10-09.md": "66acb6c8abbf0c860966223f3299c2bc", "_journal/2024-10/2024-10-08.md": "2f737d8198b12bf635808964c4887ae1", - "x86-64/procedures.md": "4f8bb79e11b710eaccaf7ecb847bd69f", + "x86-64/procedures.md": "eba67bb16589d24f235fa0fb0067f552", "_journal/2024-10-10.md": "29e4be2c164c63f8b7aab56bddee3dd6", "_journal/2024-10/2024-10-09.md": "458811cdab772a7b3dbc1dd8ae5c51ee", "_journal/2024-10-15.md": "6e696a8d16ba257ed89e8564b771d290", @@ -906,7 +908,7 @@ "_journal/2024-10/2024-10-27.md": "cba851f3ca4482b776b339b792c4c901", "_journal/2024-10/2024-10-26.md": "e69e361f941c181828c87368b18d1a1c", "_journal/2024-10/2024-10-25.md": "0597575213a2bb0e15052efa9404dd1b", - "_journal/2024-10/2024-10-24.md": "4493c339209fdd910866d126b8ebe3c6", + "_journal/2024-10/2024-10-24.md": "7a6b0b950b0492b4bf178a52a1a86de5", "_journal/2024-10-29.md": "19444fb3b9bef82b200c77a6acc33637", "_journal/2024-10/2024-10-28.md": "95bcec30eda031bf6410ff51a61b0ee3", "c17/typedefs.md": "1fcb044f12c4f16de1ef8cb4c293dd10", @@ -941,7 +943,14 @@ "_journal/2024-11/2024-11-12.md": "24c858a93c0a5063820bd96207e6f8ab", "_journal/2024-11/2024-11-11.md": "d3ad8ddc5ecdb2cc08773fdef2ce6869", "_journal/2024-11/2024-11-10.md": "38ce405754e3823c8239df44546f3b35", - "x86-64/instructions/procedures.md": "fd83b80e35454d4bca12c4cf8127cf91" + "x86-64/instructions/procedures.md": "f4e17501f64007883cd656c9a834d926", + "_journal/2024-11-19.md": "1b74d7911d7ba01b5c3adffaa8c2a0ba", + "_journal/2024-11/2024-11-18.md": "db0e4cdaa7361294c7e8a1f36897e6a6", + "_journal/2024-11-22.md": "51117030e2364dbce3a8d507dead86ae", + "_journal/2024-11/2024-11-21.md": "951b6034d60a40dbd8201c50abf0dbb9", + "_journal/2024-11/2024-11-20.md": "951b6034d60a40dbd8201c50abf0dbb9", + "_journal/2024-11/2024-11-19.md": "d879f57154cb27cb168eb1f1f430e312", + "set/cardinality.md": "499e758bc0929af06736fa2974aade60" }, "fields_dict": { "Basic": [ diff --git a/notes/_journal/2024-06/2024-06-14.md b/notes/_journal/2024-06/2024-06-14.md index a5ff0ea..65fca35 100644 --- a/notes/_journal/2024-06/2024-06-14.md +++ b/notes/_journal/2024-06/2024-06-14.md @@ -9,4 +9,4 @@ title: "2024-06-14" - [ ] Korean (Read 1 Story) * Finished most notes on [[alpha-conversion|α-conversion]]. -* Starting notes on [[functions]]. \ No newline at end of file +* Starting notes on [[set/functions]]. \ No newline at end of file diff --git a/notes/_journal/2024-06/2024-06-15.md b/notes/_journal/2024-06/2024-06-15.md index fad9788..f01121c 100644 --- a/notes/_journal/2024-06/2024-06-15.md +++ b/notes/_journal/2024-06/2024-06-15.md @@ -8,5 +8,5 @@ title: "2024-06-15" - [ ] Sheet Music (10 min.) - [ ] Korean (Read 1 Story) -* [[functions|Notes]] on injections, surjections, and bijections. +* [[set/functions|Notes]] on injections, surjections, and bijections. * Start defining [[beta-reduction|β-reduction]]. \ No newline at end of file diff --git a/notes/_journal/2024-06/2024-06-21.md b/notes/_journal/2024-06/2024-06-21.md index d1e1f53..6b1f8ec 100644 --- a/notes/_journal/2024-06/2024-06-21.md +++ b/notes/_journal/2024-06/2024-06-21.md @@ -8,5 +8,5 @@ title: "2024-06-21" - [ ] Sheet Music (10 min.) - [ ] Korean (Read 1 Story) -* Notes on [[functions#Inverses|inverses]] and [[functions#Compositions|compositions]] of functions. +* Notes on [[set/functions#Inverses|inverses]] and [[set/functions#Compositions|compositions]] of functions. * Finished Chapter 8 of "The Science of Programming" on sequential composition. \ No newline at end of file diff --git a/notes/_journal/2024-06/2024-06-22.md b/notes/_journal/2024-06/2024-06-22.md index d798304..020445f 100644 --- a/notes/_journal/2024-06/2024-06-22.md +++ b/notes/_journal/2024-06/2024-06-22.md @@ -10,5 +10,5 @@ title: "2024-06-22" * Notes on [[beta-reduction#Normal Form|β-normal forms]]. * Very basic notes on [[abstract-rewriting-systems/index|abstract rewriting systems]]. -* Additional set theory definitions ([[functions#Restrictions|restrictions]] and [[functions#Images|images]]). +* Additional set theory definitions ([[set/functions#Restrictions|restrictions]] and [[set/functions#Images|images]]). * Read chapters 2 ("Methodology") and 3 ("Properties") of "An Introduction to Ontology". \ No newline at end of file diff --git a/notes/_journal/2024-07/2024-07-17.md b/notes/_journal/2024-07/2024-07-17.md index c11ac15..e6e8afb 100644 --- a/notes/_journal/2024-07/2024-07-17.md +++ b/notes/_journal/2024-07/2024-07-17.md @@ -8,4 +8,4 @@ title: "2024-07-17" - [ ] Sheet Music (10 min.) - [ ] Korean (Read 1 Story) -* Notes on [[relations#Quotient Sets|quotient sets]], function [[functions#Kernels|kernels]], and fibers. \ No newline at end of file +* Notes on [[relations#Quotient Sets|quotient sets]], function [[set/functions#Kernels|kernels]], and fibers. \ No newline at end of file diff --git a/notes/_journal/2024-10/2024-10-24.md b/notes/_journal/2024-10/2024-10-24.md index 17719cf..75c6bfe 100644 --- a/notes/_journal/2024-10/2024-10-24.md +++ b/notes/_journal/2024-10/2024-10-24.md @@ -9,5 +9,5 @@ title: "2024-10-24" - [ ] Korean (Read 1 Story) * Finished "Recursion on $\omega$" and "Arithmetic" sections of Enderton's "Elements of Set Theory". -* Notes on recursively defined [[natural-numbers#Addition|addition]], [[natural-numbers#Multiplication|multiplication]] and [[natural-numbers#Exponentiation|exponentiation]] [[functions|operations]]. +* Notes on recursively defined [[natural-numbers#Addition|addition]], [[natural-numbers#Multiplication|multiplication]] and [[natural-numbers#Exponentiation|exponentiation]] [[set/functions|operations]]. * Notes on local stack variables and arguments passed on the stack. \ No newline at end of file diff --git a/notes/_journal/2024-11-22.md b/notes/_journal/2024-11-22.md new file mode 100644 index 0000000..0ebbf5b --- /dev/null +++ b/notes/_journal/2024-11-22.md @@ -0,0 +1,13 @@ +--- +title: "2024-11-22" +--- + +- [x] Anki Flashcards +- [x] KoL +- [x] OGS +- [ ] Sheet Music (10 min.) +- [ ] Korean (Read 1 Story) + +* Read through CS:APP's section "The Y86-64 Instruction Set Architecture". +* Added notes on the special cases of C's [[c17/declarations#main|main()]] function. +* Notes on [[cardinality#Overview|equinumerosity]]. \ No newline at end of file diff --git a/notes/_journal/2024-11-18.md b/notes/_journal/2024-11/2024-11-18.md similarity index 50% rename from notes/_journal/2024-11-18.md rename to notes/_journal/2024-11/2024-11-18.md index 4abcfb8..a1f8f00 100644 --- a/notes/_journal/2024-11-18.md +++ b/notes/_journal/2024-11/2024-11-18.md @@ -2,9 +2,9 @@ title: "2024-11-18" --- -- [ ] Anki Flashcards +- [x] Anki Flashcards - [x] KoL -- [ ] OGS +- [x] OGS - [ ] Sheet Music (10 min.) - [ ] Korean (Read 1 Story) diff --git a/notes/_journal/2024-11/2024-11-19.md b/notes/_journal/2024-11/2024-11-19.md new file mode 100644 index 0000000..22e9100 --- /dev/null +++ b/notes/_journal/2024-11/2024-11-19.md @@ -0,0 +1,11 @@ +--- +title: "2024-11-19" +--- + +- [x] Anki Flashcards +- [x] KoL +- [x] OGS +- [ ] Sheet Music (10 min.) +- [ ] Korean (Read 1 Story) + +* [[c17/declarations#Prototypes|Notes]] on prototypes, identifier type lists, and parameter type lists. \ No newline at end of file diff --git a/notes/_journal/2024-11/2024-11-20.md b/notes/_journal/2024-11/2024-11-20.md new file mode 100644 index 0000000..abcd08d --- /dev/null +++ b/notes/_journal/2024-11/2024-11-20.md @@ -0,0 +1,9 @@ +--- +title: "2024-11-21" +--- + +- [x] Anki Flashcards +- [x] KoL +- [x] OGS +- [ ] Sheet Music (10 min.) +- [ ] Korean (Read 1 Story) \ No newline at end of file diff --git a/notes/_journal/2024-11/2024-11-21.md b/notes/_journal/2024-11/2024-11-21.md new file mode 100644 index 0000000..abcd08d --- /dev/null +++ b/notes/_journal/2024-11/2024-11-21.md @@ -0,0 +1,9 @@ +--- +title: "2024-11-21" +--- + +- [x] Anki Flashcards +- [x] KoL +- [x] OGS +- [ ] Sheet Music (10 min.) +- [ ] Korean (Read 1 Story) \ No newline at end of file diff --git a/notes/algebra/polynomials.md b/notes/algebra/polynomials.md index fa5e57b..1e5da29 100644 --- a/notes/algebra/polynomials.md +++ b/notes/algebra/polynomials.md @@ -87,7 +87,7 @@ END%% %%ANKI Basic What is a binomial? -Back: A polynomial containing two terms. +Back: A polynomial containing two non-like terms. Reference: Oscar Levin, *Discrete Mathematics: An Open Introduction*, 3rd ed., n.d., [https://discrete.openmathbooks.org/pdfs/dmoi3-tablet.pdf](https://discrete.openmathbooks.org/pdfs/dmoi3-tablet.pdf). END%% diff --git a/notes/algebra/set.md b/notes/algebra/set.md index e70107e..604e764 100644 --- a/notes/algebra/set.md +++ b/notes/algebra/set.md @@ -905,7 +905,7 @@ END%% ## Index Sets -Let $I$ be a set, called the **index set**. Let $F$ be a [[functions|function]] whose domain includes $I$. Then we define $$\bigcup_{i \in I} F(i) = \bigcup\,\{F(i) \mid i \in I\}$$ +Let $I$ be a set, called the **index set**. Let $F$ be a [[set/functions|function]] whose domain includes $I$. Then we define $$\bigcup_{i \in I} F(i) = \bigcup\,\{F(i) \mid i \in I\}$$ and, if $I \neq \varnothing$, $$\bigcap_{i \in I} F(i) = \bigcap\, \{F(i) \mid i \in I\}$$ %%ANKI diff --git a/notes/c17/declarations.md b/notes/c17/declarations.md index b44006e..527bac8 100644 --- a/notes/c17/declarations.md +++ b/notes/c17/declarations.md @@ -275,6 +275,497 @@ Reference: Van der Linden, Peter. _Expert C Programming: Deep C Secrets_. Progra END%% +## Prototypes + +A function declaration/definition has two ways of using declarators: **parameter type lists** and **identifier type lists**. To make the distinction clear, consider the following two ways of defining an `add` function: + +```c +int f(int x, int y) { return x + y; } // Paramter type list +int f(x, y) int x; int y; { return x + y } // Identifier type list +``` + +A function **prototype** is a kind of function declaration that specifies the function signature. There are three important points to make note of: + +* Empty identifier lists are interpreted as "the compiler has not been told what this function's arguments are." +* The standard prohibits declaring functions with a non-empty identifier list. +* Empty parameter lists are not allowed. + +Therefore: + +```c +// Uses an empty identifer list. This declares a function `foo` +// that takes an unknown specification of arguments. +void foo(); +// Uses a non-empty identifier list. Compiler error. +void foo(x, y); +// Uses a non-empty identifier list. Compiler error. +void foo(x, y) int x; int y; +// Uses a non-empty identifier list. Definitions allow this. +void foo(x, y) int x; int y; { } +// Uses a non-empty parameter list. This prototypes a function +// `foo` that takes no arguments. +void foo(void); +// Uses a non-empty parameter list. This prototypes and defines +// a function `foo` that takes no arguments. +void foo(void) {} +``` + +Together these points imply a function prototype *must* use a parameter type list. + +%%ANKI +Basic +Which of prototypes or declarations are more general? +Back: Declarations. +Reference: “ISO: Programming Languages - C,” April 12, 2011, [https://port70.net/~nsz/c/c11/n1570.pdf](https://port70.net/~nsz/c/c11/n1570.pdf). + +END%% + +%%ANKI +Basic +What two ways are parameters declared in function declarations and definitions? +Back: Identifier type lists and parameter type lists. +Reference: “ISO: Programming Languages - C,” April 12, 2011, [https://port70.net/~nsz/c/c11/n1570.pdf](https://port70.net/~nsz/c/c11/n1570.pdf). + +END%% + +%%ANKI +Basic +Which of identifier type lists and/or parameter type lists considered obsolete? +Back: Identifier type lists. +Reference: “ISO: Programming Languages - C,” April 12, 2011, [https://port70.net/~nsz/c/c11/n1570.pdf](https://port70.net/~nsz/c/c11/n1570.pdf). + +END%% + +%%ANKI +Basic +Define an addition function using identifier type lists. +Back: +```c +int add(x, y) int x; int y; { return x + y; } +``` +Reference: “ISO: Programming Languages - C,” April 12, 2011, [https://port70.net/~nsz/c/c11/n1570.pdf](https://port70.net/~nsz/c/c11/n1570.pdf). + +END%% + +%%ANKI +Basic +Define an addition function using parameter type lists. +Back: +```c +int add(int x, int y) { return x + y; } +``` +Reference: “ISO: Programming Languages - C,” April 12, 2011, [https://port70.net/~nsz/c/c11/n1570.pdf](https://port70.net/~nsz/c/c11/n1570.pdf). + +END%% + +%%ANKI +Basic +Is the following a prototype or a declaration? +```c +void foo(); +``` +Back: A declaration. +Reference: “ISO: Programming Languages - C,” April 12, 2011, [https://port70.net/~nsz/c/c11/n1570.pdf](https://port70.net/~nsz/c/c11/n1570.pdf). + +END%% + +%%ANKI +Basic +What compilation error does the following raise? +```c +void foo(); +``` +Back: N/A. +Reference: “ISO: Programming Languages - C,” April 12, 2011, [https://port70.net/~nsz/c/c11/n1570.pdf](https://port70.net/~nsz/c/c11/n1570.pdf). + +END%% + +%%ANKI +Basic +What compilation error does the following raise? +```c +void foo(x, y); +``` +Back: A function declaration cannot have a non-empty identifier list. +Reference: “ISO: Programming Languages - C,” April 12, 2011, [https://port70.net/~nsz/c/c11/n1570.pdf](https://port70.net/~nsz/c/c11/n1570.pdf). + +END%% + +%%ANKI +Basic +What compilation error does the following raise? +```c +void foo(x, y) int x; int y; +``` +Back: A function declaration cannot have a non-empty identifier list. +Reference: “ISO: Programming Languages - C,” April 12, 2011, [https://port70.net/~nsz/c/c11/n1570.pdf](https://port70.net/~nsz/c/c11/n1570.pdf). + +END%% + +%%ANKI +Basic +What compilation error does the following raise? +```c +void foo(x, y) int x; int y; {} +``` +Back: N/A. +Reference: “ISO: Programming Languages - C,” April 12, 2011, [https://port70.net/~nsz/c/c11/n1570.pdf](https://port70.net/~nsz/c/c11/n1570.pdf). + +END%% + +%%ANKI +Basic +What function prototype is declared in the following? +```c +void foo(x, y) int x; int y; {} +``` +Back: N/A. No prototype has been declared. +Reference: “ISO: Programming Languages - C,” April 12, 2011, [https://port70.net/~nsz/c/c11/n1570.pdf](https://port70.net/~nsz/c/c11/n1570.pdf). + +END%% + +%%ANKI +Basic +What compilation error does the following raise? +```c +void foo(); + +int main(void) { foo(1); } +``` +Back: N/A. +Reference: “ISO: Programming Languages - C,” April 12, 2011, [https://port70.net/~nsz/c/c11/n1570.pdf](https://port70.net/~nsz/c/c11/n1570.pdf). + +END%% + +%%ANKI +Basic +Is the following a prototype or a declaration? +```c +void f(void); +``` +Back: A prototype. +Reference: “ISO: Programming Languages - C,” April 12, 2011, [https://port70.net/~nsz/c/c11/n1570.pdf](https://port70.net/~nsz/c/c11/n1570.pdf). + +END%% + +%%ANKI +Basic +What compilation error does the following raise? +```c +void foo(void); +``` +Back: N/A. +Reference: “ISO: Programming Languages - C,” April 12, 2011, [https://port70.net/~nsz/c/c11/n1570.pdf](https://port70.net/~nsz/c/c11/n1570.pdf). + +END%% + +%%ANKI +Basic +What compilation error does the following raise? +```c +void foo(void); + +int main(void) { foo(1); } +``` +Back: Too many arguments to function call `foo`. +Reference: “ISO: Programming Languages - C,” April 12, 2011, [https://port70.net/~nsz/c/c11/n1570.pdf](https://port70.net/~nsz/c/c11/n1570.pdf). + +END%% + +%%ANKI +Basic +What function prototype is declared in the following? +```c +void foo(int x, int y); +``` +Back: `void foo(int, int)` +Reference: “ISO: Programming Languages - C,” April 12, 2011, [https://port70.net/~nsz/c/c11/n1570.pdf](https://port70.net/~nsz/c/c11/n1570.pdf). + +END%% + +%%ANKI +Basic +What function prototype is declared in the following? +```c +void foo(int x, int y) {} +``` +Back: `void foo(int, int)` +Reference: “ISO: Programming Languages - C,” April 12, 2011, [https://port70.net/~nsz/c/c11/n1570.pdf](https://port70.net/~nsz/c/c11/n1570.pdf). + +END%% + +%%ANKI +Basic +How many arguments does the following declaration specify? +```c +void foo(); +``` +Back: Some number unknown to the compiler. +Reference: “ISO: Programming Languages - C,” April 12, 2011, [https://port70.net/~nsz/c/c11/n1570.pdf](https://port70.net/~nsz/c/c11/n1570.pdf). + +END%% + +%%ANKI +Basic +How many arguments does the following declaration specify? +```c +void foo(void); +``` +Back: Zero. +Reference: “ISO: Programming Languages - C,” April 12, 2011, [https://port70.net/~nsz/c/c11/n1570.pdf](https://port70.net/~nsz/c/c11/n1570.pdf). + +END%% + +%%ANKI +Basic +Why might the following snippet raise a compilation error? +```c +int foo(); +int foo(int a); +``` +Back: N/A. It likely wouldn't. +Reference: “ISO: Programming Languages - C,” April 12, 2011, [https://port70.net/~nsz/c/c11/n1570.pdf](https://port70.net/~nsz/c/c11/n1570.pdf). + +END%% + +%%ANKI +Basic +*Why* might the following snippet raise a compilation error? +```c +int foo(); +int foo(float a); +``` +Back: Conflicting types. The first `foo` declares any `float` passed to it default promotes to a `double`. +Reference: “ISO: Programming Languages - C,” April 12, 2011, [https://port70.net/~nsz/c/c11/n1570.pdf](https://port70.net/~nsz/c/c11/n1570.pdf). + +END%% + +%%ANKI +Basic +*Why* might the following snippet raise a compilation error? +```c +int foo(); +int foo(char a); +``` +Back: Conflicting types. The first `foo` declares any `char` passed to it default promotes to an `int`. +Reference: “ISO: Programming Languages - C,” April 12, 2011, [https://port70.net/~nsz/c/c11/n1570.pdf](https://port70.net/~nsz/c/c11/n1570.pdf). + +END%% + +%%ANKI +Basic +*Why* might the following snippet raise a compilation error? +```c +int foo(); +int foo(double a); +``` +Back: N/A. It likely wouldn't. +Reference: “ISO: Programming Languages - C,” April 12, 2011, [https://port70.net/~nsz/c/c11/n1570.pdf](https://port70.net/~nsz/c/c11/n1570.pdf). + +END%% + +### main + +`main` is a special function serving as the entrypoint to C programs. It can have several different prototypes, but the following two are always possible: + +```c +int main(void); +int main(int argc, char* argv[argc+1]); +``` + +The only two return values guaranteed to work on all platform is `EXIT_SUCCESS` and `EXIT_FAILURE`. Reaching the end of `main` is equivalent to a `reutrn` with value `EXIT_SUCCESS`. + +%%ANKI +Basic +Which function serves as the entrypoint of C programs? +Back: `main` +Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020). + +END%% + +%%ANKI +Basic +How many valid prototypes of `main` are available? +Back: Indeterminate. Depends on the system. +Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020). + +END%% + +%%ANKI +Basic +How many "official" prototypes of `main` are available? +Back: Two. +Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020). + +END%% + +%%ANKI +Basic +What are the "official" prototypes of `main`? +Back: +```c +int main(void); +int main(int argc, char* argv[argc + 1]); +``` +Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020). + +END%% + +%%ANKI +Basic +What are the "official" prototypes of `main`? +Back: +```c +int main(void); +int main(int argc, char* argv[argc + 1]); +``` +Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020). +END%% + +%%ANKI +Basic +What are the only portable values that `main` can return? +Back: `EXIT_SUCCESS` and `EXIT_FAILURE`. +Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020). + +END%% + +%%ANKI +Basic +Which library defines `EXIT_SUCCESS`? +Back: `stdlib.h` +Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020). + +END%% + +%%ANKI +Basic +Which library defines `EXIT_FAILURE`? +Back: `stdlib.h` +Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020). + +END%% + +%%ANKI +Basic +What happens when `main` does not explicitly return a value? +Back: `EXIT_SUCCESS` is implicitly returned. +Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020). + +END%% + +%%ANKI +Cloze +Returning {1:`s`} in {1:`main`} is equivalent to invoking function {2:`exit`} with argument {2:`s`}. +Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020). + +END%% + +%%ANKI +Basic +Which library declares the following prototype? +```c +noreturn void exit(int) +``` +Back: `stdlib.h` +Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020). + +END%% + +%%ANKI +Basic +What does keyword `_Noreturn` indicate? +Back: The associated callee will never return control back to the caller. +Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020). + +END%% + +%%ANKI +Basic +What kind of syntactical construct is `_Noreturn`? +Back: A special keyword. +Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020). + +END%% + +%%ANKI +Basic +What kind of syntactical construct is `noreturn`? +Back: A macro. +Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020). + +END%% + +%%ANKI +Cloze +{1:`_Noreturn`} is a {2:keyword} whereas {2:`noreturn`} is a {1:macro}. +Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020). + +END%% + +%%ANKI +Basic +Which library is `noreturn` defined in? +Back: `stdnoreturn.h` +Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020). + +END%% + +%%ANKI +Basic +Consider the following prototype. What is the value of `argv[0]`? +```c +int main(int argc, char* argv[argc + 1]); +``` +Back: The name of the program invocation. +Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020). + +END%% + +%%ANKI +Basic +Consider the following prototype. What is the value of `argv[argc]`? +```c +int main(int argc, char* argv[argc + 1]); +``` +Back: `0` +Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020). + +END%% + +%%ANKI +Basic +Consider the following prototype. What is the value of `argv[1]`? +```c +int main(int argc, char* argv[argc + 1]); +``` +Back: `0` if `argc == 1` else the first argument to the program. +Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020). + +END%% + +%%ANKI +Basic +Consider the following prototype. What is the minimum value of `argc`? +```c +int main(int argc, char* argv[argc + 1]); +``` +Back: `1` +Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020). + +END%% + +%%ANKI +Basic +Consider the following prototype. What is the minimum length of `argv`? +```c +int main(int argc, char* argv[argc + 1]); +``` +Back: `2` +Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020). + +END%% + ## Initializers An **initializer** is an expression that gives an object a value at time of declaration. Only variable-length arrays (VLAs) do not allow for an initializer. The default initializer looks like `{0}`. diff --git a/notes/c17/strings.md b/notes/c17/strings.md index 83ba1b6..c8b5b64 100644 --- a/notes/c17/strings.md +++ b/notes/c17/strings.md @@ -84,6 +84,33 @@ Tags: printf END%% +%%ANKI +Basic +What is the purpose of the width field in a `printf` argument? +Back: It specifies a minimum number of characters to ouput. +Reference: “Printf,” in *Wikipedia*, January 18, 2024, [https://en.wikipedia.org/w/index.php?title=Printf&oldid=1196716962](https://en.wikipedia.org/w/index.php?title=Printf&oldid=1196716962). +Tags: printf + +END%% + +%%ANKI +Basic +What is the purpose of the precision field in a `printf` argument? +Back: It specifies the maximum limit on the output, depending on the argument type. +Reference: “Printf,” in *Wikipedia*, January 18, 2024, [https://en.wikipedia.org/w/index.php?title=Printf&oldid=1196716962](https://en.wikipedia.org/w/index.php?title=Printf&oldid=1196716962). +Tags: printf + +END%% + +%%ANKI +Basic +What is the purpose of the length field in a `printf` argument? +Back: It specifies the size of the `printf` argument before default promotion. +Reference: “Printf,” in *Wikipedia*, January 18, 2024, [https://en.wikipedia.org/w/index.php?title=Printf&oldid=1196716962](https://en.wikipedia.org/w/index.php?title=Printf&oldid=1196716962). +Tags: printf + +END%% + %%ANKI Basic Which header file contains basic `printf` functionality? diff --git a/notes/c17/types/derived.md b/notes/c17/types/derived.md index f0bf625..af297f5 100644 --- a/notes/c17/types/derived.md +++ b/notes/c17/types/derived.md @@ -563,8 +563,8 @@ END%% Basic *Why* must FLAs be declared within a function? Back: N/A. They can exist elsewhere. -Tags: x86-64 Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. +Tags: x86-64 END%% @@ -592,8 +592,8 @@ END%% Basic *Why* do variable-length arrays require use of a frame pointer? Back: Offsets depend on how much space must be allocated on the stack. -Tags: x86-64 Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. +Tags: x86-64 END%% @@ -601,8 +601,8 @@ END%% Basic *Why* must VLAs be declared within a function? Back: Their implementation relies on frame pointers. -Tags: x86-64 Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. +Tags: x86-64 END%% diff --git a/notes/set/cardinality.md b/notes/set/cardinality.md new file mode 100644 index 0000000..3700a22 --- /dev/null +++ b/notes/set/cardinality.md @@ -0,0 +1,148 @@ +--- +title: Cardinality +TARGET DECK: Obsidian::STEM +FILE TAGS: set::cardinality +tags: + - set +--- + +## Overview + +We say set $A$ is **equinumerous** to set $B$, written ($A \approx B$) if and only if there exists a [[functions#Injections|one-to-one]] function from $A$ [[functions#Surjections|onto]] $B$. + +%%ANKI +Basic +Suppose $A$ is equinumerous to $B$. How does Enderton denote this? +Back: $A \approx B$ +Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). + +END%% + +%%ANKI +Basic +What does it mean for $A$ to be equinumerous to $B$? +Back: There exists a bijection between $A$ and $B$. +Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). + +END%% + +%%ANKI +Basic +Suppose $A \approx B$. Then what must exist? +Back: A bijection between $A$ and $B$. +Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). + +END%% + +%%ANKI +Basic +Suppose there exists a one-to-one function $F$ from $A$ into $B$. When is $A \approx B$? +Back: When $F$ is also onto $B$. +Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). + +END%% + +%%ANKI +Basic +Suppose there exists a function $F$ from $A$ onto $B$. When is $A \approx B$? +Back: When $F$ is also one-to-one. +Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). + +END%% + +%%ANKI +Basic +Suppose there exists a one-to-one function $F$ from $A$ onto $B$. When is $A \approx B$? +Back: Always, by definition. +Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). + +END%% + +## Equivalence Concept + +For any sets $A$, $B$, and $C$: + +* $A \approx A$; +* if $A \approx B$, then $B \approx A$; +* if $A \approx B$ and $B \approx C$, then $A \approx C$. + +Notice though that $\{ \langle A, B \rangle \mid A \approx B \}$ is *not* an equivalence relation since the equivalence concept of equinumerosity concerns *all* sets. + +%%ANKI +Basic +Concisely state the equivalence concept of equinumerosity in Zermelo-Fraenkel set theory. +Back: For all sets $A$, $B$, and $C$: +* $A \approx A$; +* $A \approx B \Rightarrow B \approx A$; +* $A \approx B \land B \approx C \Rightarrow A \approx C$ +Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). + +END%% + +%%ANKI +Basic +Concisely state the equivalence concept of equinumerosity in von Neumann-Bernays set theory. +Back: Class $\{ \langle A, B \rangle \mid A \approx B \}$ is reflexive on the class of all sets, symmetric, and transitive. +Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). + +END%% + +%%ANKI +Basic +What is the reflexive property of equinumerosity in FOL? +Back: $\forall A, A \approx A$ +Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). + +END%% + +%%ANKI +Basic +What is the symmetric property of equinumerosity in FOL? +Back: $\forall A, B, A \approx B \Rightarrow B \approx A$ +Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). + +END%% + +%%ANKI +Basic +What is the transitive property of equinumerosity in FOL? +Back: $\forall A, B, C, A \approx B \land B \approx C \Rightarrow A \approx C$ +Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). + +END%% + +%%ANKI +Basic +Is $\{ \langle A, B \rangle \mid A \approx B \}$ a set? +Back: No. +Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). + +END%% + +%%ANKI +Basic +*Why* isn't $\{ \langle A, B \rangle \mid A \approx B \}$ a set? +Back: Because then the field of this "relation" would be a set. +Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). + +END%% + +%%ANKI +Basic +Is $\{ \langle A, B \rangle \mid A \approx B \}$ an equivalence relation? +Back: No. +Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). + +END%% + +%%ANKI +Basic +*Why* isn't $\{ \langle A, B \rangle \mid A \approx B \}$ an equivalence relation? +Back: Because then the field of this "relation" would be a set. +Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). + +END%% + +## Bibliography + +* Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). \ No newline at end of file diff --git a/notes/x86-64/images/buffer-overflow.png b/notes/x86-64/images/buffer-overflow.png new file mode 100644 index 0000000..ba40897 Binary files /dev/null and b/notes/x86-64/images/buffer-overflow.png differ diff --git a/notes/x86-64/instructions/procedures.md b/notes/x86-64/instructions/procedures.md index 68ed93d..534a43e 100644 --- a/notes/x86-64/instructions/procedures.md +++ b/notes/x86-64/instructions/procedures.md @@ -152,7 +152,7 @@ END%% %%ANKI Basic Variable-sized frames use which of `leave` and/or `ret`? -Back: Bot +Back: Both. Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. END%% diff --git a/notes/x86-64/procedures.md b/notes/x86-64/procedures.md index 94134b7..902480b 100644 --- a/notes/x86-64/procedures.md +++ b/notes/x86-64/procedures.md @@ -585,7 +585,7 @@ END%% %%ANKI Cloze -By convention, register `%rbp` is used for {callee-saved values}. +By convention, register `%rbp` is used for {base pointers}. Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. END%% @@ -683,8 +683,8 @@ END%% %%ANKI Basic -When is the `%rbp` register used? -Back: When working with variable-sized frames. +What kind of frames use the `%rbp` register? +Back: Variable-sized frames. Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. END%% @@ -753,6 +753,23 @@ Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Program END%% +%%ANKI +Basic +Allocate an array in a stack frame. Is the start of the array nearer the stack's top or bottom? +Back: Bottom. +Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. + +END%% + +%%ANKI +Basic +Suppose an array exists in "Local variables". What region is trampled in a buffer overflow? +![[buffer-overflow.png]] +Back: The return address. +Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. + +END%% + ## Bibliography * Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.